[v2,4/4] proxy.cgi: fix subnet comparison for proxy.pac generation
Commit Message
The logic of subnet comparison is broken. E.g. if the blue netmask is
255.255.255.0, it's impossible to add a VPN subnet with the same netmask.
The fix simplifies the logic by using Network::network_equal.
---
html/cgi-bin/proxy.cgi | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
@@ -3065,9 +3065,10 @@ END
{
@temp = split(/\//);
chomp $temp[1];
- if (
- ($temp[0] ne $netsettings{'GREEN_NETADDRESS'}) && ($temp[1] ne $netsettings{'GREEN_NETMASK'}) &&
- ($temp[0] ne $netsettings{'BLUE_NETADDRESS'}) && ($temp[1] ne $netsettings{'BLUE_NETMASK'})
+ unless (
+ # GREEN or BLUE networks are already added to "DIRECT". Check if given network is different from these.
+ &Network::network_equal("$temp[0]/$temp[1]", "$netsettings{'GREEN_NETADDRESS'}/$netsettings{'GREEN_NETMASK'}") ||
+ &Network::network_equal("$temp[0]/$temp[1]", "$netsettings{'BLUE_NETADDRESS'}/$netsettings{'BLUE_NETMASK'}")
)
{
print FILE " ||\n (isInNet(myIpAddress(), \"$temp[0]\", \"$temp[1]\"))";