Hi, after some testing, i figured out, that ipMatch function is not working correctly.
Example:
Network 192.168.1.0/24 (IPs: 192.168.1.0-192.168.1.255)
ipMatch(192.168.1.1, 192.168.1.0/24) -> true, great
ipMatch(192.168.2.1, 192.168.1.0/24) -> true, what isn't nice.
Even if tests are passing:
Assert::true( Helpers::ipMatch('192.168.68.233', '192.168.68.233') );
woks fine
Assert::false( Helpers::ipMatch('192.168.68.234', '192.168.68.233') );
works fine
Assert::true( Helpers::ipMatch('192.168.64.0', '192.168.68.233/12') );
Network 192.168.68.233/12 (IPs: 192.160.0.1-192.175.255.255)
fine, it's in subnet
Assert::false( Helpers::ipMatch('192.168.63.255', '192.168.68.233/12') );
not fine, even in subnet, but returns false
Assert::true( Helpers::ipMatch('192.168.79.254', '192.168.68.233/12') );
fine, in subnet
Assert::false( Helpers::ipMatch('192.168.80.0', '192.168.68.233/12') );
in subnet, but returns false
Assert::true( Helpers::ipMatch('127.0.0.1', '192.168.68.233/32') );
not sure, if this should return true
Maybe I missunderstood something, but this is how Mikrotik and Cisco devices are interpreting CIDR network.
Maybe, the logic of function is working backwards...
| real |
expected |
addresses |
| /0 |
/32 |
1 |
| /1 |
/31 |
2 |
| /2 |
/30 |
4 |
| /3 |
/29 |
8 |
| ... |
... |
... |
| /12 |
/20 |
4096 |
If I use 192.168.68.233/20 (192.168.64.0-192.168.79.255), it matches expected behaviour as seen in tests..
Hi, after some testing, i figured out, that ipMatch function is not working correctly.
Example:
Network 192.168.1.0/24 (IPs: 192.168.1.0-192.168.1.255)
ipMatch(192.168.1.1, 192.168.1.0/24) -> true, great
ipMatch(192.168.2.1, 192.168.1.0/24) -> true, what isn't nice.
Even if tests are passing:
woks fine
works fine
Network 192.168.68.233/12 (IPs: 192.160.0.1-192.175.255.255)
fine, it's in subnet
not fine, even in subnet, but returns false
fine, in subnet
in subnet, but returns false
not sure, if this should return true
Maybe I missunderstood something, but this is how Mikrotik and Cisco devices are interpreting CIDR network.
Maybe, the logic of function is working backwards...
If I use 192.168.68.233/20 (192.168.64.0-192.168.79.255), it matches expected behaviour as seen in tests..