]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/proxy.cgi
squid / WPAD: Add GUI for exception-files for generation of proxy.pac
[ipfire-2.x.git] / html / cgi-bin / proxy.cgi
index 09e6b33a1575bfe50767c7610a615eea4652d6f0..55fdc1c35a01fd0bb021b4088f667ec232a75d11 100644 (file)
@@ -56,7 +56,7 @@ my %mainsettings=();
 my %checked=();
 my %selected=();
 
-my @throttle_limits=(64,128,256,384,512,768,1024,1280,1536,1792,2048,2560,3072,3584,4096,5120,6144,7168,8192,10240,12288,16384,20480);
+my @throttle_limits=(64,128,256,512,1024,1536,2048,3072,4096,5120,6144,7168,8192,10240,16384,20480,51200,102400);
 
 my $def_ports_safe="80 # http\n21 # ftp\n443 # https\n563 # snews\n70 # gopher\n210 # wais\n1025-65535 # unregistered ports\n280 # http-mgmt\n488 # gss-http\n591 # filemaker\n777 # multiling http\n800 # Squids port (for icons)\n";
 my $def_ports_ssl="443 # https\n563 # snews\n";
@@ -101,7 +101,7 @@ my $cre_svhosts = "${General::swroot}/proxy/advanced/cre/supervisors";
 
 my $identhosts = "$identdir/hosts";
 
-my $authdir  = "/usr/lib/squid/";
+my $authdir  = "/usr/lib/squid";
 my $errordir = "/usr/lib/squid/errors";
 
 my $acl_src_subnets = "$acldir/src_subnets.acl";
@@ -124,6 +124,9 @@ my $acl_ports_safe = "$acldir/ports_safe.acl";
 my $acl_ports_ssl  = "$acldir/ports_ssl.acl";
 my $acl_include = "$acldir/include.acl";
 
+my $acl_dst_noproxy_url = "$acldir/dst_noproxy_url.acl";
+my $acl_dst_noproxy_ip = "$acldir/dst_noproxy_ip.acl";
+
 my $updaccelversion  = 'n/a';
 my $urlfilterversion = 'n/a';
 
@@ -188,7 +191,7 @@ $proxysettings{'TRANSPARENT_PORT'} = '3128';
 $proxysettings{'VISIBLE_HOSTNAME'} = '';
 $proxysettings{'ADMIN_MAIL_ADDRESS'} = '';
 $proxysettings{'ADMIN_PASSWORD'} = '';
-$proxysettings{'ERR_LANGUAGE'} = 'German';
+$proxysettings{'ERR_LANGUAGE'} = 'en';
 $proxysettings{'ERR_DESIGN'} = 'ipfire';
 $proxysettings{'SUPPRESS_VERSION'} = 'off';
 $proxysettings{'FORWARD_VIA'} = 'off';
@@ -203,8 +206,8 @@ $proxysettings{'CACHEMGR'} = 'off';
 $proxysettings{'LOGQUERY'} = 'off';
 $proxysettings{'LOGUSERAGENT'} = 'off';
 $proxysettings{'FILEDESCRIPTORS'} = '16384';
-$proxysettings{'CACHE_MEM'} = '2';
-$proxysettings{'CACHE_SIZE'} = '50';
+$proxysettings{'CACHE_MEM'} = '128';
+$proxysettings{'CACHE_SIZE'} = '0';
 $proxysettings{'MAX_SIZE'} = '4096';
 $proxysettings{'MIN_SIZE'} = '0';
 $proxysettings{'MEM_POLICY'} = 'LRU';
@@ -556,6 +559,8 @@ ERROR:
                delete $proxysettings{'SRC_UNRESTRICTED_MAC'};
                delete $proxysettings{'DST_NOCACHE'};
                delete $proxysettings{'DST_NOAUTH'};
+               delete $proxysettings{'DST_NOPROXY_IP'};
+               delete $proxysettings{'DST_NOPROXY_URL'};
                delete $proxysettings{'PORTS_SAFE'};
                delete $proxysettings{'PORTS_SSL'};
                delete $proxysettings{'MIME_TYPES'};
@@ -1315,6 +1320,58 @@ END
 ;
 }
 
+# ===================================================================
+#  WPAD settings
+# ===================================================================
+
+print <<END
+<table width='100%'>
+<tr>
+       <td colspan='4'><b>$Lang::tr{'advproxy wpad title'}</b></td>
+</tr>
+<tr>
+       <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
+</tr>
+<tr>
+       <td colspan='2' class='base'>$Lang::tr{'advproxy wpad label dst_noproxy_ip'}:</td>
+       <td colspan='2' class='base'>$Lang::tr{'advproxy wpad label dst_noproxy_url'}:</td>
+</tr>
+<tr>
+       <td colspan='2'><textarea name='DST_NOPROXY_IP' cols='32' rows='3' wrap='off'>
+END
+;
+
+       print $proxysettings{'DST_NOPROXY_IP'};
+
+print <<END
+</textarea></td>
+
+       <td colspan='2'><textarea name='DST_NOPROXY_URL' cols='32' rows='3' wrap='off'>
+END
+;
+
+       print $proxysettings{'DST_NOPROXY_URL'};
+
+print <<END
+</textarea></td>
+</tr>
+<tr>
+       <td colspan='2' class='base'>$Lang::tr{'advproxy wpad example dst_noproxy_ip'}</td>
+       <td colspan='2' class='base'>$Lang::tr{'advproxy wpad example dst_noproxy_url'}</td>
+</tr>
+<tr>
+       <td colspan="4">&nbsp;</td>
+</tr>
+<tr>
+       <td colspan="4">$Lang::tr{'advproxy wpad view pac'}: <a href="http://$ENV{SERVER_ADDR}:81/wpad.dat" target="_blank">http://$ENV{SERVER_ADDR}:81/wpad.dat</a></td>
+</tr>
+</table>
+
+<hr size='1'>
+
+END
+;
+
 # -------------------------------------------------------------------
 
 print <<END
@@ -1430,7 +1487,15 @@ END
 ;
 
 foreach (@throttle_limits) {
-       print "\t<option value='$_' $selected{'THROTTLING_GREEN_TOTAL'}{$_}>$_ kbit/s</option>\n";
+       my $val = $_;
+       my $unit = "kbit/s";
+
+       if ($val >= 1024) {
+               $unit = "Mbit/s";
+               $val /= 1024;
+       }
+
+       print "\t<option value='$_' $selected{'THROTTLING_GREEN_TOTAL'}{$_}>$val $unit</option>\n";
 }
 
 print <<END
@@ -2250,6 +2315,18 @@ sub read_acls
                while (<FILE>) { $proxysettings{'DST_NOAUTH'} .= $_ };
                close(FILE);
        }
+       if (-e "$acl_dst_noproxy_ip") {
+               open(FILE,"$acl_dst_noproxy_ip");
+               delete $proxysettings{'DST_NOPROXY_IP'};
+               while (<FILE>) { $proxysettings{'DST_NOPROXY_IP'} .= $_ };
+               close(FILE);
+       }
+       if (-e "$acl_dst_noproxy_url") {
+               open(FILE,"$acl_dst_noproxy_url");
+               delete $proxysettings{'DST_NOPROXY_URL'};
+               while (<FILE>) { $proxysettings{'DST_NOPROXY_URL'} .= $_ };
+               close(FILE);
+       }
        if (-e "$acl_ports_safe") {
                open(FILE,"$acl_ports_safe");
                delete $proxysettings{'PORTS_SAFE'};
@@ -2435,6 +2512,31 @@ sub check_acls
                }
        }
 
+       @temp = split(/\n/,$proxysettings{'DST_NOPROXY_IP'});
+       undef $proxysettings{'DST_NOPROXY_IP'};
+       foreach (@temp)
+       {
+                       s/^\s+//g; s/\s+$//g;
+                       if ($_)
+                       {
+                                       unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg wpad invalid ip or mask'}; }
+                                       $proxysettings{'DST_NOPROXY_IP'} .= $_."\n";
+                       }
+       }
+
+       @temp = split(/\n/,$proxysettings{'DST_NOPROXY_URL'});
+       undef $proxysettings{'DST_NOPROXY_URL'};
+       foreach (@temp)
+       {
+                       s/^\s+//g;
+                       unless (/^#/) { s/\s+//g; }
+                       if ($_)
+                       {
+                                       if (/^\./) { $_ = '*'.$_; }
+                                       $proxysettings{'DST_NOPROXY_URL'} .= $_."\n";
+                       }
+       }
+
        if (($proxysettings{'NTLM_ENABLE_ACL'} eq 'on') && ($proxysettings{'NTLM_USER_ACL'} eq 'positive'))
        {
                @temp = split(/\n/,$proxysettings{'NTLM_ALLOW_USERS'});
@@ -2573,6 +2675,16 @@ sub write_acls
        print FILE $proxysettings{'DST_NOAUTH'};
        close(FILE);
 
+       open(FILE, ">$acl_dst_noproxy_ip");
+       flock(FILE, 2);
+       print FILE $proxysettings{'DST_NOPROXY_IP'};
+       close(FILE);
+
+       open(FILE, ">$acl_dst_noproxy_url");
+       flock(FILE, 2);
+       print FILE $proxysettings{'DST_NOPROXY_URL'};
+       close(FILE);
+
        open(FILE, ">$acl_dst_noauth_net");
        close(FILE);
        open(FILE, ">$acl_dst_noauth_dom");
@@ -2755,6 +2867,43 @@ END
                print FILE "     (isInNet(host, \"$netsettings{'ORANGE_NETADDRESS'}\", \"$netsettings{'ORANGE_NETMASK'}\")) ||\n";
        }
 
+       # Additional exceptions for URLs
+       # The file has to be created by the user and should contain one entry per line
+       # Line-Format: <URL incl. wildcards>
+       # e.g. *.ipfire.org*
+       if (-s "$acl_dst_noproxy_url") {
+               undef @templist;
+
+               open(NOPROXY,"$acl_dst_noproxy_url");
+               @templist = <NOPROXY>;
+               close(NOPROXY);
+               chomp (@templist);
+
+               foreach (@templist)
+               {
+                       print FILE "     (shExpMatch(url, \"$_\")) ||\n";
+               }
+       }
+
+       # Additional exceptions for Subnets
+       # The file has to be created by the user and should contain one entry per line
+       # Line-Format: <IP>/<SUBNET MASK>
+       # e.g. 192.168.0.0/255.255.255.0
+       if (-s "$acl_dst_noproxy_ip") {
+               undef @templist;
+
+               open(NOPROXY,"$acl_dst_noproxy_ip");
+               @templist = <NOPROXY>;
+               close(NOPROXY);
+               chomp (@templist);
+
+               foreach (@templist)
+               {
+                       @temp = split(/\//);
+                       print FILE "     (isInNet(host, \"$temp[0]\", \"$temp[1]\")) ||\n";
+               }
+       }
+
        print FILE <<END
      (isInNet(host, "169.254.0.0", "255.255.0.0"))
    )