• Resolved ecafaller

    (@ecafaller)


    Hi,

    I am having an issue where WP_FAIL2BAN_PROXIES does not work if i put in a network range (ie 192.168.1.0/24). It works fine if I put a single proxy IP address in there. I have a bunch of proxy servers that I would rather put a range in instead of a list. Anyone else find this issue?

    Thanks,

    Al

    https://www.ads-software.com/plugins/wp-fail2ban/

Viewing 2 replies - 1 through 2 (of 2 total)
  • I found this problem in version 2.2.1. I fixed it. The XOR operator was confused with the pow function and the precedence of an AND operator disagreed with a comparison.

    Here’s a patch.

    @@ -50,12 +50,12 @@
     			foreach(explode(',',WP_FAIL2BAN_PROXIES) as $proxy) {
     				if (2 == count($cidr = explode('/',$proxy))) {
     					$net = ip2long($cidr[0]);
    -					$mask = ~ ( (2 ^ (32 - $cidr[1])) - 1 );
    +					$mask = ~ ( pow(2, (32 - $cidr[1])) - 1 );
     				} else {
     					$net = ip2long($proxy);
     					$mask = -1;
     				}
    -				if ($net == $ip & $mask) {
    +				if ($net == ($ip & $mask)) {
     					return (false===($len = strpos($_SERVER['HTTP_X_FORWARDED_FOR'],',')))
     							? $_SERVER['HTTP_X_FORWARDED_FOR']
     							: substr($_SERVER['HTTP_X_FORWARDED_FOR'],0,$len);
    Plugin Author invisnet

    (@invisnet)

    Thanks for that – I’ve added it for 2.3.0.

    One of the perils of working in many languages is that sometimes you don’t spot obvious things….

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WP_FAIL2BAN_PROXIES does not work with network range’ is closed to new replies.