]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/proxy.cgi
GeoIP: update database to 05092012.
[people/teissler/ipfire-2.x.git] / html / cgi-bin / proxy.cgi
index a387d3e75f8b7042dc4c6bd195608995b7802557..015502a4e5fda106006447a12eb60591479487da 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2009  Michael Tremer & Christian Schmidt                      #
+# Copyright (C) 2007-2012  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -55,10 +55,10 @@ my %mainsettings=();
 my %checked=();
 my %selected=();
 
-my @throttle_limits=(64,128,256,384,512,1024,2048,3072,5120);
-my $throttle_binary="bin|cab|exe|gz|rar|sea|tar|tgz|zip";
-my $throttle_dskimg="b5t|bin|bwt|ccd|cdi|cue|gho|img|iso|mds|nrg|pqi";
-my $throttle_mmedia="aiff?|asf|avi|divx|mov|mp3|mpe?g|qt|ra?m";
+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_binary="7z|arj|bin|bz2|cab|exe|gz|lzh|rar|sea|tar|tgz|xz|zip";
+my $throttle_dskimg="b5t|bin|bwt|ccd|cdi|cue|gho|img|iso|mds|nrg|pqi|vmdk";
+my $throttle_mmedia="aiff?|asf|avi|divx|mov|mp3|mpe?g|ogg|qt|ra?m|ts|vob";
 
 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";
@@ -82,7 +82,6 @@ my @templist=();
 my $cachemem=0;
 my $proxy1='';
 my $proxy2='';
-my $replybodymaxsize=0;
 my $browser_regexp='';
 my $needhup = 0;
 my $errormessage='';
@@ -354,6 +353,13 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'}
                $errormessage = $Lang::tr{'advproxy errmsg invalid proxy port'};
                goto ERROR;
        }
+       if (!($proxysettings{'UPSTREAM_PROXY'} eq '')) {
+         my @temp = split(/:/,$proxysettings{'UPSTREAM_PROXY'});
+         if (!(&General::validip($temp[0]))) {
+           $errormessage = $Lang::tr{'advproxy errmsg invalid upstream proxy'};
+           goto ERROR;
+          }
+        }
        if (!($proxysettings{'CACHE_SIZE'} =~ /^\d+/) ||
                ($proxysettings{'CACHE_SIZE'} < 10))
        {
@@ -985,7 +991,7 @@ print <<END
 <tr><td class='base' >$Lang::tr{'processes'}<input type='text' name='CHILDREN' value='$proxysettings{'CHILDREN'}' size='5' /></td>
 END
 ;
-my $count = `arp -a | wc -l`;
+my $count = `ip n| wc -l`;
 if ( $count < 1 ){$count = 1;}
 if ( -e "/usr/bin/squidclamav" ) {
        print "<td class='base'><b>".$Lang::tr{'advproxy squidclamav'}."</b><br />";
@@ -2925,6 +2931,7 @@ sub writepacfile
 if (
      (isPlainHostName(host)) ||
      (dnsDomainIs(host, ".$mainsettings{'DOMAINNAME'}")) ||
+     (isInNet(host, "127.0.0.1", "255.0.0.0")) ||
      (isInNet(host, "10.0.0.0", "255.0.0.0")) ||
      (isInNet(host, "172.16.0.0", "255.240.0.0")) ||
      (isInNet(host, "192.168.0.0", "255.255.0.0")) ||
@@ -3013,7 +3020,7 @@ sub writeconfig
        }
 
        $_ = $proxysettings{'UPSTREAM_PROXY'};
-       my ($remotehost, $remoteport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
+        my ($remotehost, $remoteport) = split(/:/,$_);
 
        if ($remoteport eq '') { $remoteport = 80; }
 
@@ -3075,19 +3082,12 @@ cache_mem $proxysettings{'CACHE_MEM'} MB
 END
        ;
 
-       if ($proxysettings{'CACHE_SIZE'} eq '0')
+       if ($proxysettings{'CACHE_SIZE'} ne '0')
        {
-               print FILE "cache_dir null /var/tmp\n\n";
-       } else {
                print FILE "cache_dir aufs /var/log/cache $proxysettings{'CACHE_SIZE'} $proxysettings{'L1_DIRS'} 256\n\n";
        }
 
-       if (($proxysettings{'ERR_DESIGN'} eq 'ipfire' ))
-       {
-               print FILE "error_directory $errordir.ipfire/$proxysettings{'ERR_LANGUAGE'}\n\n";
-       } else {
-               print FILE "error_directory $errordir/$proxysettings{'ERR_LANGUAGE'}\n\n";
-       }
+       print FILE "error_directory $errordir/$proxysettings{'ERR_LANGUAGE'}\n\n";
 
        if ($proxysettings{'OFFLINE_MODE'} eq 'on') {  print FILE "offline_mode on\n\n"; }
 
@@ -3154,6 +3154,7 @@ END
 
                if ($proxysettings{'AUTH_METHOD'} eq 'ldap')
                {
+                       print FILE "auth_param basic utf8 on\n";
                        print FILE "auth_param basic program $authdir/squid_ldap_auth -b \"$proxysettings{'LDAP_BASEDN'}\"";
                        if (!($proxysettings{'LDAP_BINDDN_USER'} eq '')) { print FILE " -D \"$proxysettings{'LDAP_BINDDN_USER'}\""; }
                        if (!($proxysettings{'LDAP_BINDDN_PASS'} eq '')) { print FILE " -w $proxysettings{'LDAP_BINDDN_PASS'}"; }
@@ -3200,7 +3201,7 @@ END
                {
                        if ($proxysettings{'NTLM_ENABLE_INT_AUTH'} eq 'on')
                        {
-                               print FILE "auth_param ntlm program $authdir/ntlm_auth $proxysettings{'NTLM_DOMAIN'}/$proxysettings{'NTLM_PDC'}";
+                               print FILE "auth_param ntlm program $authdir/ntlm_smb_lm_auth $proxysettings{'NTLM_DOMAIN'}/$proxysettings{'NTLM_PDC'}";
                                if ($proxysettings{'NTLM_BDC'} eq '') { print FILE "\n"; } else { print FILE " $proxysettings{'NTLM_DOMAIN'}/$proxysettings{'NTLM_BDC'}\n"; }
                                print FILE "auth_param ntlm children $proxysettings{'AUTH_CHILDREN'}\n";
                                if (!($proxysettings{'AUTH_IPCACHE_TTL'} eq '0')) { print FILE "\nauthenticate_ip_ttl $proxysettings{'AUTH_IPCACHE_TTL'} minutes\n"; }
@@ -3374,8 +3375,7 @@ acl IPFire_no_access_mac arp "$acl_src_noaccess_mac"
 END
                ;
                print FILE "deny_info ";
-               if ((($proxysettings{'ERR_DESIGN'} eq 'ipfire') && (-e "$errordir.ipfire/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED")) ||
-                   (($proxysettings{'ERR_DESIGN'} eq 'squid') && (-e "$errordir/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED")))
+               if (($proxysettings{'ERR_DESIGN'} eq 'squid') && (-e "$errordir/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED"))
                {
                        print FILE "ERR_ACCESS_DISABLED";
                } else {
@@ -3383,8 +3383,7 @@ END
                }
                print FILE " IPFire_no_access_ips\n";
                print FILE "deny_info ";
-               if ((($proxysettings{'ERR_DESIGN'} eq 'ipfire') && (-e "$errordir.ipfire/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED")) ||
-                   (($proxysettings{'ERR_DESIGN'} eq 'squid') && (-e "$errordir/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED")))
+               if (($proxysettings{'ERR_DESIGN'} eq 'squid') && (-e "$errordir/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED"))
                {
                        print FILE "ERR_ACCESS_DISABLED";
                } else {
@@ -3879,19 +3878,18 @@ END
 request_body_max_size $proxysettings{'MAX_OUTGOING_SIZE'} KB
 END
        ;
-       $replybodymaxsize = 1024 * $proxysettings{'MAX_INCOMING_SIZE'};
        if ($proxysettings{'MAX_INCOMING_SIZE'} > 0) {
-               if (!-z $acl_src_unrestricted_ip) { print FILE "reply_body_max_size 0 deny IPFire_unrestricted_ips\n"; }
-               if (!-z $acl_src_unrestricted_mac) { print FILE "reply_body_max_size 0 deny IPFire_unrestricted_mac\n"; }
+               if (!-z $acl_src_unrestricted_ip) { print FILE "reply_body_max_size none IPFire_unrestricted_ips\n"; }
+               if (!-z $acl_src_unrestricted_mac) { print FILE "reply_body_max_size none IPFire_unrestricted_mac\n"; }
                if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
                {
-                       if (!-z $extgrp) { print FILE "reply_body_max_size 0 deny for_extended_users\n"; }
+                       if (!-z $extgrp) { print FILE "reply_body_max_size none for_extended_users\n"; }
                }
        }
        
-       if ( $replybodymaxsize != '0' )
+       if ( $proxysettings{'MAX_INCOMING_SIZE'} != '0' )
        {
-               print FILE "reply_body_max_size $replybodymaxsize deny all\n\n";
+               print FILE "reply_body_max_size $proxysettings{'MAX_INCOMING_SIZE'} KB all\n\n";
        }
 
        print FILE "visible_hostname";
@@ -3932,6 +3930,11 @@ END
                print FILE "url_rewrite_program /usr/sbin/redirect_wrapper\n";
                print FILE "url_rewrite_children $proxysettings{'CHILDREN'}\n\n";
        }
+
+       # Include file with user defined settings.
+       if (-e "/etc/squid/squid.conf.local") {
+               print FILE "include /etc/squid/squid.conf.local\n";
+       }
        close FILE;
 }