X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Fproxy.cgi;h=a387d3e75f8b7042dc4c6bd195608995b7802557;hb=7274a673f0e2941c17c0745285d2f46f97728db3;hp=1a4453a777c1dc12670dfe2be838c8aa238f14d7;hpb=cab25d67ad7f0b0efec2332ae9dddf3c8d380e89;p=people%2Fteissler%2Fipfire-2.x.git
diff --git a/html/cgi-bin/proxy.cgi b/html/cgi-bin/proxy.cgi
index 1a4453a77..a387d3e75 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) 2008 Michael Tremer & Christian Schmidt #
+# Copyright (C) 2009 Michael Tremer & Christian Schmidt #
# #
# 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 #
@@ -19,11 +19,11 @@
# #
###############################################################################
#
-# (c) 2004-2008 marco.s - http://www.advproxy.net
+# (c) 2004-2009 marco.s - http://www.advproxy.net
#
# This code is distributed under the terms of the GPL
#
-# $Id: advproxy.cgi,v 3.0.0 2008/08/18 00:00:00 marco.s Exp $
+# $Id: advproxy.cgi,v 3.0.2 2009/02/04 00:00:00 marco.s Exp $
#
use strict;
@@ -180,6 +180,12 @@ close(FILE);
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&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'}) {
+ $blue_cidr = &General::ipcidr("$netsettings{'BLUE_NETADDRESS'}\/$netsettings{'BLUE_NETMASK'}");
+}
+
&Header::showhttpheaders();
$proxysettings{'ACTION'} = '';
@@ -192,6 +198,7 @@ $proxysettings{'TRANSPARENT_BLUE'} = 'off';
$proxysettings{'PROXY_PORT'} = '800';
$proxysettings{'VISIBLE_HOSTNAME'} = '';
$proxysettings{'ADMIN_MAIL_ADDRESS'} = '';
+$proxysettings{'ADMIN_PASSWORD'} = '';
$proxysettings{'ERR_LANGUAGE'} = 'German';
$proxysettings{'ERR_DESIGN'} = 'ipfire';
$proxysettings{'SUPPRESS_VERSION'} = 'off';
@@ -203,8 +210,10 @@ $proxysettings{'UPSTREAM_PROXY'} = '';
$proxysettings{'UPSTREAM_USER'} = '';
$proxysettings{'UPSTREAM_PASSWORD'} = '';
$proxysettings{'LOGGING'} = 'off';
+$proxysettings{'CACHEMGR'} = 'off';
$proxysettings{'LOGQUERY'} = 'off';
$proxysettings{'LOGUSERAGENT'} = 'off';
+$proxysettings{'FILEDESCRIPTORS'} = '4096';
$proxysettings{'CACHE_MEM'} = '2';
$proxysettings{'CACHE_SIZE'} = '50';
$proxysettings{'MAX_SIZE'} = '4096';
@@ -331,7 +340,7 @@ if ($proxysettings{'ACTION'} eq $Lang::tr{'edit'})
$proxysettings{'NCSA_PASS_CONFIRM'} = $proxysettings{'NCSA_PASS'};
}
-if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'}))
+if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'}) || ($proxysettings{'ACTION'} eq $Lang::tr{'proxy reconfigure'}))
{
if ($proxysettings{'ENABLE'} !~ /^(on|off)$/ ||
$proxysettings{'TRANSPARENT'} !~ /^(on|off)$/ ||
@@ -354,6 +363,12 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'}
goto ERROR;
}
}
+ if (!($proxysettings{'FILEDESCRIPTORS'} =~ /^\d+/) ||
+ ($proxysettings{'FILEDESCRIPTORS'} < 1) || ($proxysettings{'FILEDESCRIPTORS'} > 16384))
+ {
+ $errormessage = $Lang::tr{'proxy errmsg filedescriptors'};
+ goto ERROR;
+ }
if (!($proxysettings{'CACHE_MEM'} =~ /^\d+/) ||
($proxysettings{'CACHE_MEM'} < 1))
{
@@ -625,6 +640,8 @@ ERROR:
&writeconfig;
&writepacfile;
+ if ($proxysettings{'CACHEMGR'} eq 'on'){&writecachemgr;}
+
system ('/usr/local/bin/squidctrl', 'disable');
unlink "${General::swroot}/proxy/enable";
unlink "${General::swroot}/proxy/transparent";
@@ -643,7 +660,8 @@ ERROR:
system ('/usr/bin/touch', "${General::swroot}/proxy/transparent_blue"); }
if ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'}) { system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); }
- }
+ if ($proxysettings{'ACTION'} eq $Lang::tr{'proxy reconfigure'}) { system('/usr/local/bin/squidctrl reconfigure >/dev/null 2>&1'); }
+ }
}
if ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy clear cache'})
@@ -704,6 +722,9 @@ $checked{'OFFLINE_MODE'}{$proxysettings{'OFFLINE_MODE'}} = "checked='checked'";
$checked{'LOGGING'}{'off'} = '';
$checked{'LOGGING'}{'on'} = '';
$checked{'LOGGING'}{$proxysettings{'LOGGING'}} = "checked='checked'";
+$checked{'CACHEMGR'}{'off'} = '';
+$checked{'CACHEMGR'}{'on'} = '';
+$checked{'CACHEMGR'}{$proxysettings{'CACHEMGR'}} = "checked='checked'";
$checked{'LOGQUERY'}{'off'} = '';
$checked{'LOGQUERY'}{'on'} = '';
$checked{'LOGQUERY'}{$proxysettings{'LOGQUERY'}} = "checked='checked'";
@@ -915,8 +936,7 @@ if ($netsettings{'BLUE_DEV'}) {
print "
| ";
}
print <$Lang::tr{'advproxy admin mail'}:
- |
+ |
END
@@ -969,8 +989,13 @@ my $count = `arp -a | wc -l`;
if ( $count < 1 ){$count = 1;}
if ( -e "/usr/bin/squidclamav" ) {
print "".$Lang::tr{'advproxy squidclamav'}." ";
- print $Lang::tr{'advproxy enabled'}." ";
- print "+ ".int(( $count**(1/3)) * 8);
+ if ( ! -e "/var/run/clamav/clamd.pid" ){
+ print "clamav not running
";
+ $proxysettings{'ENABLE_CLAMAV'} = 'off';
+ }
+ else {
+ print $Lang::tr{'advproxy enabled'}." ";
+ print "+ ".int(( $count**(1/3)) * 8);}
print " | ";
} else {
print " | ";
@@ -1038,6 +1063,18 @@ print <
$Lang::tr{'advproxy cache management'} |
+
+ $Lang::tr{'proxy cachemgr'}: |
+ |
+ $Lang::tr{'advproxy admin mail'}: |
+ |
+
+
+ $Lang::tr{'proxy filedescriptors'}: |
+ |
+ $Lang::tr{'proxy admin password'}: |
+ |
+
| | | |
@@ -1162,10 +1199,10 @@ END
if (!$proxysettings{'SRC_SUBNETS'})
{
- print "$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}\n";
+ print "$green_cidr\n";
if ($netsettings{'BLUE_DEV'})
{
- print "$netsettings{'BLUE_NETADDRESS'}\/$netsettings{'BLUE_NETMASK'}\n";
+ print "$blue_cidr\n";
}
} else { print $proxysettings{'SRC_SUBNETS'}; }
@@ -1754,9 +1791,9 @@ print <
|
|
+ |
|
|
|
@@ -2543,6 +2581,7 @@ sub check_acls
}
@temp = split(/\n/,$proxysettings{'DST_NOAUTH'});
+ undef $proxysettings{'DST_NOAUTH'};
foreach (@temp)
{
s/^\s+//g;
@@ -2659,10 +2698,10 @@ sub write_acls
flock(FILE, 2);
if (!$proxysettings{'SRC_SUBNETS'})
{
- print FILE "$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}\n";
+ print FILE "$green_cidr\n";
if ($netsettings{'BLUE_DEV'})
{
- print FILE "$netsettings{'BLUE_NETADDRESS'}\/$netsettings{'BLUE_NETMASK'}\n";
+ print FILE "$blue_cidr\n";
}
} else { print FILE $proxysettings{'SRC_SUBNETS'}; }
close(FILE);
@@ -3015,7 +3054,7 @@ END
print FILE "cache deny no_cache_domains\n";
}
if (!-z $acl_dst_nocache_net) {
- print FILE "acl no_cache_domains dst \"$acl_dst_nocache_net\"\n";
+ print FILE "acl no_cache_ipaddr dst \"$acl_dst_nocache_net\"\n";
print FILE "cache deny no_cache_ipaddr\n";
}
if (!-z $acl_dst_nocache_url) {
@@ -3031,7 +3070,6 @@ cache_effective_group squid
umask 022
pid_filename /var/run/squid.pid
-max_filedescriptors 4096
cache_mem $proxysettings{'CACHE_MEM'} MB
END
@@ -3287,8 +3325,8 @@ END
}
print FILE <) {
$_ =~ s/__GREEN_IP__/$netsettings{'GREEN_ADDRESS'}/;
- $_ =~ s/__GREEN_NET__/$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}/;
+ $_ =~ s/__GREEN_NET__/$green_cidr/;
$_ =~ s/__BLUE_IP__/$blue_ip/;
$_ =~ s/__BLUE_NET__/$blue_net/;
$_ =~ s/__PROXY_PORT__/$proxysettings{'PROXY_PORT'}/;
@@ -3779,19 +3817,23 @@ END
if ($proxysettings{'FORWARD_IPADDRESS'} eq 'off')
{
- print FILE "header_access X-Forwarded-For deny all\n";
+ print FILE "request_header_access X-Forwarded-For deny all\n";
+ print FILE "reply_header_access X-Forwarded-For deny all\n";
}
if ($proxysettings{'FORWARD_VIA'} eq 'off')
{
- print FILE "header_access Via deny all\n";
+ print FILE "request_header_access Via deny all\n";
+ print FILE "reply_header_access Via deny all\n";
}
if (!($proxysettings{'FAKE_USERAGENT'} eq ''))
{
- print FILE "header_access User-Agent deny all\n";
+ print FILE "request_header_access User-Agent deny all\n";
+ print FILE "reply_header_access User-Agent deny all\n";
}
if (!($proxysettings{'FAKE_REFERER'} eq ''))
{
- print FILE "header_access Referer deny all\n";
+ print FILE "request_header_access Referer deny all\n";
+ print FILE "reply_header_access Referer deny all\n";
}
print FILE "\n";
@@ -3839,14 +3881,18 @@ 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 allow IPFire_unrestricted_ips\n"; }
- if (!-z $acl_src_unrestricted_mac) { print FILE "reply_body_max_size 0 allow IPFire_unrestricted_mac\n"; }
+ 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 ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
{
- if (!-z $extgrp) { print FILE "reply_body_max_size 0 allow for_extended_users\n"; }
+ if (!-z $extgrp) { print FILE "reply_body_max_size 0 deny for_extended_users\n"; }
}
}
- print FILE "reply_body_max_size $replybodymaxsize allow all\n\n";
+
+ if ( $replybodymaxsize != '0' )
+ {
+ print FILE "reply_body_max_size $replybodymaxsize deny all\n\n";
+ }
print FILE "visible_hostname";
if ($proxysettings{'VISIBLE_HOSTNAME'} eq '')
@@ -3856,7 +3902,11 @@ END
print FILE " $proxysettings{'VISIBLE_HOSTNAME'}\n\n";
}
- if (!($proxysettings{'ADMIN_MAIL_ADDRESS'} eq '')) { print FILE "cache_mgr $proxysettings{'ADMIN_MAIL_ADDRESS'}\n\n"; }
+ if (!($proxysettings{'ADMIN_MAIL_ADDRESS'} eq '')) { print FILE "cache_mgr $proxysettings{'ADMIN_MAIL_ADDRESS'}\n"; }
+ if (!($proxysettings{'ADMIN_PASSWORD'} eq '')) { print FILE "cachemgr_passwd $proxysettings{'ADMIN_PASSWORD'} all\n"; }
+ print FILE "\n";
+
+ print FILE "max_filedescriptors $proxysettings{'FILEDESCRIPTORS'}\n\n";
# Write the parent proxy info, if needed.
if ($remotehost ne '')
@@ -3954,3 +4004,15 @@ sub deluser
}
# -------------------------------------------------------------------
+
+sub writecachemgr
+{
+ open(FILE, ">${General::swroot}/proxy/cachemgr.conf");
+ flock(FILE, 2);
+ print FILE "$netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}\n";
+ print FILE "localhost";
+ close(FILE);
+ return;
+}
+
+# -------------------------------------------------------------------