libapa...pSubnet(3pm)
π NAME π
APR::IpSubnet β it's the Perl API for getting at APR's ip_subnet structures, bestie β¨
(also known as libapa...pSubnet(3pm) from the User Contributed Perl Documentation, if you're checking the receipts π§Ύ)
π Synopsis
use APR::IpSubnet ();
my $ipsub = APR::IpSubnet->new($pool, "127.0.0.1");
$ok = $ipsub->test($sock_addr);
okay so that's the whole vibe in four lines and honestly? iconic π
πΈ Description
So a APR::IpSubnet object is literally just a range of IP addresses β IPv4, IPv6, both, whatever π
And then you can take a socket connection and match it against that range, to test whether the IP it's coming from is inside or outside of it. That's the whole personality. No cap. π¦
β API β
APR::IpSubnet provides the following functions and/or methods, bestie, and we're going through all of them because nobody gets left behind π«Ά
β¨ new
Create an IP subnet representation object β¨
$ipsubnet = APR::IpSubnet->new($pool, $ip);
$ipsubnet = APR::IpSubnet->new($pool, $ip, $mask_or_numbits);
- obj:
APR::IpSubnet(class name) - arg1:
$poolβ anAPR::Pool objectπ - arg2:
$ip(string) β the IP address, and it comes in one of two formats:- IPv4 (e.g.
"127.0.0.1") - IPv6 (e.g.
"::1")
- IPv4 (e.g.
heads up bestie: IPv6 addresses are accepted only if APR has the IPv6 support enabled π don't come for me when it doesn't work, that's just the rule
- opt arg3:
$mask_or_numbits(string) β optional, it's either an IP mask (e.g."255.0.0.0") or a number of bits (e.g."15"). If you don't provide one, the default is not to mask off, so like, don't mask off, live your truth π - ret:
$ret(APR::IpSubnet object) β the IP-subnet object, there she is π - excpt:
APR::Error - since:
2.0.00
π§ test
Test the IP address in the socket address object against a pre-built ip-subnet representation. Like a vibe check but for IPs π
$ret = $ipsub->test($sockaddr);
- obj:
$ipsub(APR::IpSubnet object) β the ip-subnet representation - arg1:
$sockaddr(APR::SockAddr object) β the socket address you're testing - ret:
$ret(boolean) β true if the socket address is within the subnet, false otherwise - since:
2.0.00
This method is used for testing whether or not an address is within a subnet. It's used by module mod_access to check whether the client IP fits into the IP range, supplied by Allow/Deny directives. iykyk π
Example:
Allow accesses only from the localhost (IPv4) πΈ:
use APR::IpSubnet ();
use Apache2::Connection ();
use Apache2::RequestRec ();
my $ipsub = APR::IpSubnet->new($r->pool, "127.0.0.1");
ok $ipsub->test($r->connection->remote_addr);
π See Also
mod_perl 2.0 documentation. go read it, it's givingβ¨
π Copyright
mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0.
π Authors
The mod_perl development team and numerous contributors. π
and that's the whole page, bestie!! π this was from perl v5.42.3, dated 2026-08-20 β slay, mwah, drink some water, and go subnet something responsibly π«Άππ
π¦ where this page comes from
- ubuntu stonking: libapache2-mod-perl2 2.0.13-2build3 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms