Support for IPv6 and CIDR in black-/whitelist
-
Hi,
with most of my sites running on native Dual Stack servers and increasing numbers of IPv6 clients black- and whitelists should support IPv6 addresses.
I had a look into the code and apparently the use of
ip2long()
does not support that, so simply entering a range like2001:db8::1-2001:db8:ffff:ffff:ffff:ffff:ffff:ffff
does not lead to any valid result.Please consider adding support for that.
A bonus would be CIDR notation support, s.t. the above example can be reduced to
2001:db8::/32
.I’ve added a Gist for migration of the existing code to
inet_pton
(which supports IPv6 if PHP supports it):
https://gist.github.com/stklcode/59447dd8419ad79d2bcd5d38d733ea65For CIDR match an example implementation can be found in one of my plugins (required some boilerplate to be compatible with current range notation):
https://github.com/stklcode/statify-blacklist/blob/f14ceac40081617cef1d588ea725f1f8d5fb3117/inc/class-statifyblacklist.php#L294-L365Cheers,
Stefan
- The topic ‘Support for IPv6 and CIDR in black-/whitelist’ is closed to new replies.