X-Git-Url: http://git.ipfire.org/?p=people%2Fteissler%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fproxy.cgi;h=c8f0dca77f490970c488f9f9ea49980c1b455c4b;hp=6d0fe545e3b4798f67c1bc86dea613253160354e;hb=631b67b7cd4c5fa00417cbe9e843892cae6f0ff6;hpb=7b321c2cbe910caeb0d5887cc4f4dc15836dd473 diff --git a/html/cgi-bin/proxy.cgi b/html/cgi-bin/proxy.cgi index 6d0fe545e..c8f0dca77 100644 --- a/html/cgi-bin/proxy.cgi +++ b/html/cgi-bin/proxy.cgi @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2011 IPFire Team # +# Copyright (C) 2007-2013 IPFire Team # # # # 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"; @@ -180,8 +180,8 @@ close(FILE); &General::readhash("${General::swroot}/main/settings", \%mainsettings); my $green_cidr = &General::ipcidr("$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}"); -my $blue_cidr = "# Blue not defined"; -if ($netsettings{'BLUE_DEV'}) { +my $blue_cidr = ""; +if (&Header::blue_used() && $netsettings{'BLUE_DEV'}) { $blue_cidr = &General::ipcidr("$netsettings{'BLUE_NETADDRESS'}\/$netsettings{'BLUE_NETMASK'}"); } @@ -195,6 +195,7 @@ $proxysettings{'ENABLE_BLUE'} = 'off'; $proxysettings{'TRANSPARENT'} = 'off'; $proxysettings{'TRANSPARENT_BLUE'} = 'off'; $proxysettings{'PROXY_PORT'} = '800'; +$proxysettings{'TRANSPARENT_PORT'} = '3128'; $proxysettings{'VISIBLE_HOSTNAME'} = ''; $proxysettings{'ADMIN_MAIL_ADDRESS'} = ''; $proxysettings{'ADMIN_PASSWORD'} = ''; @@ -212,7 +213,7 @@ $proxysettings{'LOGGING'} = 'off'; $proxysettings{'CACHEMGR'} = 'off'; $proxysettings{'LOGQUERY'} = 'off'; $proxysettings{'LOGUSERAGENT'} = 'off'; -$proxysettings{'FILEDESCRIPTORS'} = '4096'; +$proxysettings{'FILEDESCRIPTORS'} = '16384'; $proxysettings{'CACHE_MEM'} = '2'; $proxysettings{'CACHE_SIZE'} = '50'; $proxysettings{'MAX_SIZE'} = '4096'; @@ -221,6 +222,7 @@ $proxysettings{'MEM_POLICY'} = 'LRU'; $proxysettings{'CACHE_POLICY'} = 'LRU'; $proxysettings{'L1_DIRS'} = '16'; $proxysettings{'OFFLINE_MODE'} = 'off'; +$proxysettings{'CACHE_DIGESTS'} = 'off'; $proxysettings{'CLASSROOM_EXT'} = 'off'; $proxysettings{'SUPERVISOR_PASSWORD'} = ''; $proxysettings{'NO_PROXY_LOCAL'} = 'off'; @@ -348,11 +350,37 @@ 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 (!(&General::validport($proxysettings{'TRANSPARENT_PORT'}))) + { + $errormessage = $Lang::tr{'advproxy errmsg invalid proxy port'}; + goto ERROR; + } + if ($proxysettings{'PROXY_PORT'} eq $proxysettings{'TRANSPARENT_PORT'}) { + $errormessage = $Lang::tr{'advproxy errmsg proxy ports equal'}; + 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)) { @@ -363,7 +391,7 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'} } } if (!($proxysettings{'FILEDESCRIPTORS'} =~ /^\d+/) || - ($proxysettings{'FILEDESCRIPTORS'} < 1) || ($proxysettings{'FILEDESCRIPTORS'} > 16384)) + ($proxysettings{'FILEDESCRIPTORS'} < 1) || ($proxysettings{'FILEDESCRIPTORS'} > 1048576)) { $errormessage = $Lang::tr{'proxy errmsg filedescriptors'}; goto ERROR; @@ -500,8 +528,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'})) { @@ -678,6 +709,16 @@ if (!$errormessage) &read_acls; } +# ------------------------------------------------------------------ + +# Hook to regenerate the configuration files, if cgi got called from command line. +if ($ENV{"REMOTE_ADDR"} eq "") { + writeconfig(); + exit(0); +} + +# ------------------------------------------------------------------- + $checked{'ENABLE'}{'off'} = ''; $checked{'ENABLE'}{'on'} = ''; $checked{'ENABLE'}{$proxysettings{'ENABLE'}} = "checked='checked'"; @@ -717,6 +758,9 @@ $selected{'L1_DIRS'}{$proxysettings{'L1_DIRS'}} = "selected='selected'"; $checked{'OFFLINE_MODE'}{'off'} = ''; $checked{'OFFLINE_MODE'}{'on'} = ''; $checked{'OFFLINE_MODE'}{$proxysettings{'OFFLINE_MODE'}} = "checked='checked'"; +$checked{'CACHE_DIGESTS'}{'off'} = ''; +$checked{'CACHE_DIGESTS'}{'on'} = ''; +$checked{'CACHE_DIGESTS'}{$proxysettings{'CACHE_DIGESTS'}} = "checked='checked'"; $checked{'LOGGING'}{'off'} = ''; $checked{'LOGGING'}{'on'} = ''; @@ -922,8 +966,8 @@ print < $Lang::tr{'advproxy transparent on'} Green: - $Lang::tr{'advproxy visible hostname'}: * - + $Lang::tr{'advproxy proxy port transparent'}: + END @@ -935,7 +979,8 @@ if ($netsettings{'BLUE_DEV'}) { print " "; } print <  + $Lang::tr{'advproxy visible hostname'}: * + END @@ -984,7 +1029,7 @@ print <$Lang::tr{'processes'} END ; -my $count = `arp -a | wc -l`; +my $count = `ip n| wc -l`; if ( $count < 1 ){$count = 1;} if ( -e "/usr/bin/squidclamav" ) { print "".$Lang::tr{'advproxy squidclamav'}."
"; @@ -1150,6 +1195,10 @@ print <$Lang::tr{'advproxy offline mode'}: + + $Lang::tr{'advproxy cache-digest'}: + +
@@ -1157,7 +1206,7 @@ print <$Lang::tr{'advproxy destination ports'} - + @@ -1629,8 +1678,8 @@ print <$Lang::tr{'advproxy fake referer'}: * - - + +
$Lang::tr{'advproxy standard ports'}:

@@ -3013,7 +3062,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; } @@ -3033,16 +3082,32 @@ icp_port 0 END ; + + # Include file with user defined settings. + if (-e "/etc/squid/squid.conf.pre.local") { + print FILE "include /etc/squid/squid.conf.pre.local\n\n"; + } + print FILE "http_port $netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}"; - if ($proxysettings{'TRANSPARENT'} eq 'on') { print FILE " transparent" } if ($proxysettings{'NO_CONNECTION_AUTH'} eq 'on') { print FILE " no-connection-auth" } print FILE "\n"; + if ($proxysettings{'TRANSPARENT'} eq 'on') { + print FILE "http_port $netsettings{'GREEN_ADDRESS'}:$proxysettings{'TRANSPARENT_PORT'} intercept"; + if ($proxysettings{'NO_CONNECTION_AUTH'} eq 'on') { print FILE " no-connection-auth" } + print FILE "\n"; + } + if ($netsettings{'BLUE_DEV'} && $proxysettings{'ENABLE_BLUE'} eq 'on') { print FILE "http_port $netsettings{'BLUE_ADDRESS'}:$proxysettings{'PROXY_PORT'}"; - if ($proxysettings{'TRANSPARENT_BLUE'} eq 'on') { print FILE " transparent" } if ($proxysettings{'NO_CONNECTION_AUTH'} eq 'on') { print FILE " no-connection-auth" } print FILE "\n"; + + if ($proxysettings{'TRANSPARENT_BLUE'} eq 'on') { + print FILE "http_port $netsettings{'BLUE_ADDRESS'}:$proxysettings{'TRANSPARENT_PORT'} intercept"; + if ($proxysettings{'NO_CONNECTION_AUTH'} eq 'on') { print FILE " no-connection-auth" } + print FILE "\n"; + } } if ($proxysettings{'CACHE_SIZE'} > 0) @@ -3074,16 +3139,11 @@ 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"; } - + if ($proxysettings{'CACHE_DIGESTS'} eq 'on') { print FILE "digest_generation on\n\n"; } else { print FILE "digest_generation off\n\n"; } + if ((!($proxysettings{'MEM_POLICY'} eq 'LRU')) || (!($proxysettings{'CACHE_POLICY'} eq 'LRU'))) { if (!($proxysettings{'MEM_POLICY'} eq 'LRU')) @@ -3097,15 +3157,20 @@ 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 <; close PORTS; @@ -3414,6 +3474,18 @@ END close (ACL); } if ((!-z $extgrp) && ($proxysettings{'AUTH_METHOD'} eq 'ncsa') && ($proxysettings{'NCSA_BYPASS_REDIR'} eq 'on')) { print FILE "\nredirector_access deny for_extended_users\n"; } + + # Check if squidclamav is enabled. + if ($proxysettings{'ENABLE_CLAMAV'} eq 'on') { + print FILE "\n#Settings for squidclamav:\n"; + print FILE "http_port 127.0.0.1:$proxysettings{'PROXY_PORT'}\n"; + print FILE "acl purge method PURGE\n"; + print FILE "http_access deny to_localhost\n"; + print FILE "http_access allow localhost\n"; + print FILE "http_access allow purge localhost\n"; + print FILE "http_access deny purge\n"; + print FILE "url_rewrite_access deny localhost\n"; + } print FILE <