]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/proxy.cgi
Merge branch 'iptables-upnpfw' into core67-merge
[ipfire-2.x.git] / html / cgi-bin / proxy.cgi
index 8c9574cd5e0fbbfb694c4229b8e3e5b18fd9d405..cc7416a9439ba86fb54bc8d41f3fa8e4e2dfb738 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2012  IPFire Team  <info@ipfire.org>                     #
+# Copyright (C) 2007-2013  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        #
@@ -348,11 +348,28 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'}
                $errormessage = $Lang::tr{'invalid input'};
                goto ERROR;
        }
+       if($proxysettings{'CACHE_MEM'} > $proxysettings{'CACHE_SIZE'} && $proxysettings{'CACHE_SIZE'} > 0){
+               $errormessage = $Lang::tr{'advproxy errmsg cache'}." ".$proxysettings{'CACHE_MEM'}." > ".$proxysettings{'CACHE_SIZE'};
+               goto ERROR;
+       }
+       
        if (!(&General::validport($proxysettings{'PROXY_PORT'})))
        {
                $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])))
+               {
+                       if (!(&General::validdomainname($temp[0])))
+                       {
+                               $errormessage = $Lang::tr{'advproxy errmsg invalid upstream proxy'};
+                               goto ERROR;
+                       }
+               }
+        }
        if (!($proxysettings{'CACHE_SIZE'} =~ /^\d+/) ||
                ($proxysettings{'CACHE_SIZE'} < 10))
        {
@@ -500,8 +517,11 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'}
                }
                if (!&General::validip($proxysettings{'LDAP_SERVER'}))
                {
-                       $errormessage = $Lang::tr{'advproxy errmsg ldap server'};
-                       goto ERROR;
+                       if (!&General::validdomainname($proxysettings{'LDAP_SERVER'}))
+                       {
+                               $errormessage = $Lang::tr{'advproxy errmsg ldap server'};
+                               goto ERROR;
+                       }
                }
                if (!&General::validport($proxysettings{'LDAP_PORT'}))
                {
@@ -984,7 +1004,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 />";
@@ -3013,7 +3033,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; }
 
@@ -3074,12 +3094,6 @@ pid_filename /var/run/squid.pid
 cache_mem $proxysettings{'CACHE_MEM'} MB
 END
        ;
-
-       if ($proxysettings{'CACHE_SIZE'} ne '0')
-       {
-               print FILE "cache_dir aufs /var/log/cache $proxysettings{'CACHE_SIZE'} $proxysettings{'L1_DIRS'} 256\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"; }
@@ -3097,6 +3111,11 @@ END
                print FILE "\n";
        }
 
+       if ($proxysettings{'CACHE_SIZE'} ne '0')
+       {
+               print FILE "cache_dir aufs /var/log/cache $proxysettings{'CACHE_SIZE'} $proxysettings{'L1_DIRS'} 256\n\n";
+       }
+
        if ($proxysettings{'LOGGING'} eq 'on')
        {
                print FILE <<END
@@ -3537,15 +3556,15 @@ if ($delaypools) {
 
 if ($proxysettings{'NO_PROXY_LOCAL'} eq 'on')
 {
-       print FILE "#Prevent internal proxy access to Green\n";
-       print FILE "http_access deny IPFire_green_servers !IPFire_green_network\n\n";
+       print FILE "#Prevent internal proxy access to Green except IPFire itself\n";
+       print FILE "http_access deny IPFire_green_servers !IPFire_ips !IPFire_green_network\n\n";
 }
 
 if ($proxysettings{'NO_PROXY_LOCAL_BLUE'} eq 'on')
 {
-       print FILE "#Prevent internal proxy access from Blue\n";
+       print FILE "#Prevent internal proxy access from Blue except IPFire itself\n";
        print FILE "http_access allow IPFire_blue_network IPFire_blue_servers\n";
-       print FILE "http_access deny  IPFire_blue_network IPFire_servers\n\n";
+       print FILE "http_access deny  IPFire_blue_network !IPFire_ips IPFire_servers\n\n";
 }
 
        print FILE <<END
@@ -3923,6 +3942,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;
 }