]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/proxy.cgi
BUG 11696: VPN Subnets missing from wpad.dat
[ipfire-2.x.git] / html / cgi-bin / proxy.cgi
index 91e4fcee83203640b7a437269a1a875f19484b92..b639640817a1c1ae2013123dd83d5a89409684ef 100644 (file)
@@ -2848,6 +2848,10 @@ sub write_acls
 
 sub writepacfile
 {
+       my %vpnconfig=();
+       my %ovpnconfig=();
+       &General::readhasharray("${General::swroot}/vpn/config", \%vpnconfig);
+       &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%ovpnconfig);
        open(FILE, ">/srv/web/ipfire/html/proxy.pac");
        flock(FILE, 2);
        print FILE "function FindProxyForURL(url, host)\n";
@@ -2910,6 +2914,27 @@ END
                }
        }
 
+       foreach my $key (sort { uc($vpnconfig{$a}[1]) cmp uc($vpnconfig{$b}[1]) } keys %vpnconfig) {
+               if ($vpnconfig{$key}[0] eq 'on' && $vpnconfig{$key}[3] ne 'host') {
+                       my @networks = split(/\|/, $vpnconfig{$key}[11]);
+                       foreach my $network (@networks) {
+                               my ($vpnip, $vpnsub) = split("/", $network);
+                               $vpnsub = &Network::convert_prefix2netmask($vpnsub) || $vpnsub;
+                               print FILE "     (isInNet(host, \"$vpnip\", \"$vpnsub\")) ||\n";
+                       }
+               }
+       }
+
+       foreach my $key (sort { uc($ovpnconfig{$a}[1]) cmp uc($ovpnconfig{$b}[1]) } keys %ovpnconfig) {
+               if ($ovpnconfig{$key}[0] eq 'on' && $ovpnconfig{$key}[3] ne 'host') {
+                       my @networks = split(/\|/, $ovpnconfig{$key}[11]);
+                       foreach my $network (@networks) {
+                               my ($vpnip, $vpnsub) = split("/", $network);
+                               print FILE "     (isInNet(host, \"$vpnip\", \"$vpnsub\")) ||\n";
+                       }
+               }
+       }
+
        print FILE <<END
      (isInNet(host, "169.254.0.0", "255.255.0.0"))
    )