]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/proxy.cgi
proxy.cgi: Fix for Bug #12826 'squid >=5 crashes on literal IPv6 addresses'
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / proxy.cgi
CommitLineData
ac1cfefa 1#!/usr/bin/perl
70df8302
MT
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
6323e908 5# Copyright (C) 2007-2021 IPFire Team <info@ipfire.org> #
70df8302
MT
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
ac1cfefa
MT
21
22use strict;
0aff7b81 23use Apache::Htpasswd;
bb5ca283 24use Scalar::Util qw(looks_like_number);
ac1cfefa
MT
25
26# enable only the following on debugging purpose
cb5e9c6c
CS
27#use warnings;
28#use CGI::Carp 'fatalsToBrowser';
ac1cfefa 29
ed38f89d 30require '/var/ipfire/general-functions.pl';
ac1cfefa
MT
31require "${General::swroot}/lang.pl";
32require "${General::swroot}/header.pl";
33
e698090e
SS
34require "${General::swroot}/ids-functions.pl";
35
87504199 36my @squidversion = &General::system_output("/usr/sbin/squid", "-v");
363fb6af
MT
37my $http_port='81';
38my $https_port='444';
39
18322edf
CS
40my %color = ();
41my %mainsettings = ();
42&General::readhash("${General::swroot}/main/settings", \%mainsettings);
8186b372 43&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);
18322edf 44
ac1cfefa
MT
45my %proxysettings=();
46my %netsettings=();
ed38f89d 47my %filtersettings=();
9fb25b1c 48my %xlratorsettings=();
ed38f89d 49my %stdproxysettings=();
ac1cfefa 50my %mainsettings=();
ed38f89d
MT
51
52my %checked=();
53my %selected=();
54
ce1f04ee 55my @throttle_limits=(64,128,256,512,1024,1536,2048,3072,4096,5120,6144,7168,8192,10240,16384,20480,51200,102400);
ed38f89d 56
363fb6af
MT
57my $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";
58my $def_ports_ssl="443 # https\n563 # snews\n";
59
ed38f89d
MT
60my $hintcolour='#FFFFCC';
61my $ncsa_buttontext='';
62my $language='';
63my $i=0;
64my $n=0;
65my $id=0;
66my $line='';
67my $user='';
68my @userlist=();
69my @grouplist=();
70my @temp=();
71my @templist=();
72
73my $cachemem=0;
74my $proxy1='';
75my $proxy2='';
ed38f89d
MT
76my $browser_regexp='';
77my $needhup = 0;
78my $errormessage='';
79
80my $acldir = "${General::swroot}/proxy/advanced/acls";
81my $ncsadir = "${General::swroot}/proxy/advanced/ncsa";
ed38f89d
MT
82my $raddir = "${General::swroot}/proxy/advanced/radius";
83my $identdir = "${General::swroot}/proxy/advanced/ident";
84my $credir = "${General::swroot}/proxy/advanced/cre";
85
86my $userdb = "$ncsadir/passwd";
87my $stdgrp = "$ncsadir/standard.grp";
88my $extgrp = "$ncsadir/extended.grp";
89my $disgrp = "$ncsadir/disabled.grp";
90
ed38f89d
MT
91my $mimetypes = "${General::swroot}/proxy/advanced/mimetypes";
92my $throttled_urls = "${General::swroot}/proxy/advanced/throttle";
93
94my $cre_enabled = "${General::swroot}/proxy/advanced/cre/enable";
95my $cre_groups = "${General::swroot}/proxy/advanced/cre/classrooms";
96my $cre_svhosts = "${General::swroot}/proxy/advanced/cre/supervisors";
97
98my $identhosts = "$identdir/hosts";
99
d50a7822 100my $authdir = "/usr/lib/squid";
f1baee3e 101my $errordir = "/usr/lib/squid/errors";
ed38f89d
MT
102
103my $acl_src_subnets = "$acldir/src_subnets.acl";
104my $acl_src_banned_ip = "$acldir/src_banned_ip.acl";
105my $acl_src_banned_mac = "$acldir/src_banned_mac.acl";
106my $acl_src_unrestricted_ip = "$acldir/src_unrestricted_ip.acl";
107my $acl_src_unrestricted_mac = "$acldir/src_unrestricted_mac.acl";
108my $acl_src_noaccess_ip = "$acldir/src_noaccess_ip.acl";
109my $acl_src_noaccess_mac = "$acldir/src_noaccess_mac.acl";
ed38f89d 110my $acl_dst_noauth = "$acldir/dst_noauth.acl";
488d1b7c
CS
111my $acl_dst_noauth_dom = "$acldir/dst_noauth_dom.acl";
112my $acl_dst_noauth_net = "$acldir/dst_noauth_net.acl";
113my $acl_dst_noauth_url = "$acldir/dst_noauth_url.acl";
114my $acl_dst_nocache = "$acldir/dst_nocache.acl";
115my $acl_dst_nocache_dom = "$acldir/dst_nocache_dom.acl";
116my $acl_dst_nocache_net = "$acldir/dst_nocache_net.acl";
117my $acl_dst_nocache_url = "$acldir/dst_nocache_url.acl";
ed38f89d 118my $acl_dst_throttle = "$acldir/dst_throttle.acl";
363fb6af
MT
119my $acl_ports_safe = "$acldir/ports_safe.acl";
120my $acl_ports_ssl = "$acldir/ports_ssl.acl";
ed38f89d
MT
121my $acl_include = "$acldir/include.acl";
122
ddc5602a
AK
123my $acl_dst_noproxy_url = "$acldir/dst_noproxy_url.acl";
124my $acl_dst_noproxy_ip = "$acldir/dst_noproxy_ip.acl";
125
363fb6af
MT
126my $updaccelversion = 'n/a';
127my $urlfilterversion = 'n/a';
128
ed38f89d
MT
129unless (-d "$acldir") { mkdir("$acldir"); }
130unless (-d "$ncsadir") { mkdir("$ncsadir"); }
ed38f89d
MT
131unless (-d "$raddir") { mkdir("$raddir"); }
132unless (-d "$identdir") { mkdir("$identdir"); }
133unless (-d "$credir") { mkdir("$credir"); }
134
66191888
MT
135unless (-e $cre_groups) { &General::system("touch", "$cre_groups"); }
136unless (-e $cre_svhosts) { &General::system("touch $cre_svhosts"); }
137
138unless (-e $userdb) { &General::system("touch", "$userdb"); }
139unless (-e $stdgrp) { &General::system("touch", "$stdgrp"); }
140unless (-e $extgrp) { &General::system("touch", "$extgrp"); }
141unless (-e $disgrp) { &General::system("touch", "$disgrp"); }
142
143unless (-e $acl_src_subnets) { &General::system("touch", "$acl_src_subnets"); }
144unless (-e $acl_src_banned_ip) { &General::system("touch", "$acl_src_banned_ip"); }
145unless (-e $acl_src_banned_mac) { &General::system("touch", "$acl_src_banned_mac"); }
146unless (-e $acl_src_unrestricted_ip) { &General::system("touch", "$acl_src_unrestricted_ip"); }
147unless (-e $acl_src_unrestricted_mac) { &General::system("touch", "$acl_src_unrestricted_mac"); }
148unless (-e $acl_src_noaccess_ip) { &General::system("touch", "$acl_src_noaccess_ip"); }
149unless (-e $acl_src_noaccess_mac) { &General::system("touch", "$acl_src_noaccess_mac"); }
150unless (-e $acl_dst_noauth) { &General::system("touch", "$acl_dst_noauth"); }
151unless (-e $acl_dst_noauth_dom) { &General::system("touch", "$acl_dst_noauth_dom"); }
152unless (-e $acl_dst_noauth_net) { &General::system("touch", "$acl_dst_noauth_net"); }
153unless (-e $acl_dst_noauth_url) { &General::system("touch", "$acl_dst_noauth_url"); }
154unless (-e $acl_dst_nocache) { &General::system("touch", "$acl_dst_nocache"); }
155unless (-e $acl_dst_nocache_dom) { &General::system("touch", "$acl_dst_nocache_dom"); }
156unless (-e $acl_dst_nocache_net) { &General::system("touch", "$acl_dst_nocache_net"); }
157unless (-e $acl_dst_nocache_url) { &General::system("touch", "$acl_dst_nocache_url"); }
158unless (-e $acl_dst_throttle) { &General::system("touch", "$acl_dst_throttle"); }
159unless (-e $acl_ports_safe) { &General::system("touch", "$acl_ports_safe"); }
160unless (-e $acl_ports_ssl) { &General::system("touch", "$acl_ports_ssl"); }
161unless (-e $acl_include) { &General::system("touch", "$acl_include"); }
162
163unless (-e $mimetypes) { &General::system("touch", "$mimetypes"); }
ed38f89d 164
603248db
MT
165my $HAVE_NTLM_AUTH = (-e "/usr/bin/ntlm_auth");
166
ac1cfefa
MT
167&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
168&General::readhash("${General::swroot}/main/settings", \%mainsettings);
169
ee4b5bbb
MT
170my $green_cidr = "";
171if (&Header::green_used() && $netsettings{'GREEN_DEV'}) {
172 $green_cidr = &General::ipcidr("$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}");
173}
174
d3527a38
MT
175my $blue_cidr = "";
176if (&Header::blue_used() && $netsettings{'BLUE_DEV'}) {
f09a0af5
AF
177 $blue_cidr = &General::ipcidr("$netsettings{'BLUE_NETADDRESS'}\/$netsettings{'BLUE_NETMASK'}");
178}
179
ac1cfefa
MT
180&Header::showhttpheaders();
181
182$proxysettings{'ACTION'} = '';
183$proxysettings{'VALID'} = '';
184
ac1cfefa
MT
185$proxysettings{'ENABLE'} = 'off';
186$proxysettings{'ENABLE_BLUE'} = 'off';
ac1cfefa
MT
187$proxysettings{'TRANSPARENT'} = 'off';
188$proxysettings{'TRANSPARENT_BLUE'} = 'off';
ed38f89d 189$proxysettings{'PROXY_PORT'} = '800';
0f6b6067 190$proxysettings{'TRANSPARENT_PORT'} = '3128';
ed38f89d
MT
191$proxysettings{'VISIBLE_HOSTNAME'} = '';
192$proxysettings{'ADMIN_MAIL_ADDRESS'} = '';
fe1656d2 193$proxysettings{'ADMIN_PASSWORD'} = '';
7ec83993 194$proxysettings{'ERR_LANGUAGE'} = 'en';
0d948999 195$proxysettings{'ERR_DESIGN'} = 'ipfire';
ed38f89d
MT
196$proxysettings{'FORWARD_VIA'} = 'off';
197$proxysettings{'FORWARD_IPADDRESS'} = 'off';
198$proxysettings{'FORWARD_USERNAME'} = 'off';
363fb6af 199$proxysettings{'NO_CONNECTION_AUTH'} = 'off';
ed38f89d
MT
200$proxysettings{'UPSTREAM_PROXY'} = '';
201$proxysettings{'UPSTREAM_USER'} = '';
202$proxysettings{'UPSTREAM_PASSWORD'} = '';
203$proxysettings{'LOGGING'} = 'off';
fe1656d2 204$proxysettings{'CACHEMGR'} = 'off';
ed38f89d
MT
205$proxysettings{'LOGQUERY'} = 'off';
206$proxysettings{'LOGUSERAGENT'} = 'off';
8dc17705 207$proxysettings{'FILEDESCRIPTORS'} = '16384';
c2f1b818
MT
208$proxysettings{'CACHE_MEM'} = '128';
209$proxysettings{'CACHE_SIZE'} = '0';
ac1cfefa
MT
210$proxysettings{'MAX_SIZE'} = '4096';
211$proxysettings{'MIN_SIZE'} = '0';
ed38f89d
MT
212$proxysettings{'MEM_POLICY'} = 'LRU';
213$proxysettings{'CACHE_POLICY'} = 'LRU';
214$proxysettings{'L1_DIRS'} = '16';
215$proxysettings{'OFFLINE_MODE'} = 'off';
6bea848d 216$proxysettings{'CACHE_DIGESTS'} = 'off';
ed38f89d
MT
217$proxysettings{'CLASSROOM_EXT'} = 'off';
218$proxysettings{'SUPERVISOR_PASSWORD'} = '';
9fb25b1c
MT
219$proxysettings{'NO_PROXY_LOCAL'} = 'off';
220$proxysettings{'NO_PROXY_LOCAL_BLUE'} = 'off';
ed38f89d
MT
221$proxysettings{'TIME_ACCESS_MODE'} = 'allow';
222$proxysettings{'TIME_FROM_HOUR'} = '00';
223$proxysettings{'TIME_FROM_MINUTE'} = '00';
224$proxysettings{'TIME_TO_HOUR'} = '24';
225$proxysettings{'TIME_TO_MINUTE'} = '00';
ac1cfefa
MT
226$proxysettings{'MAX_OUTGOING_SIZE'} = '0';
227$proxysettings{'MAX_INCOMING_SIZE'} = '0';
ed38f89d
MT
228$proxysettings{'THROTTLING_GREEN_TOTAL'} = 'unlimited';
229$proxysettings{'THROTTLING_GREEN_HOST'} = 'unlimited';
230$proxysettings{'THROTTLING_BLUE_TOTAL'} = 'unlimited';
231$proxysettings{'THROTTLING_BLUE_HOST'} = 'unlimited';
bb5ca283
PM
232$proxysettings{'ASNBL_FASTFLUX_DETECTION'} = 'off';
233$proxysettings{'ASNBL_FASTFLUX_THRESHOLD'} = '5';
234$proxysettings{'ASNBL_SELECANN_DETECTION'} = 'off';
ed38f89d 235$proxysettings{'ENABLE_MIME_FILTER'} = 'off';
ed38f89d
MT
236$proxysettings{'AUTH_METHOD'} = 'none';
237$proxysettings{'AUTH_REALM'} = '';
238$proxysettings{'AUTH_MAX_USERIP'} = '';
239$proxysettings{'AUTH_CACHE_TTL'} = '60';
0f8251fe 240$proxysettings{'AUTH_IPCACHE_TTL'} = '0';
ed38f89d
MT
241$proxysettings{'AUTH_CHILDREN'} = '5';
242$proxysettings{'NCSA_MIN_PASS_LEN'} = '6';
243$proxysettings{'NCSA_BYPASS_REDIR'} = 'off';
244$proxysettings{'NCSA_USERNAME'} = '';
245$proxysettings{'NCSA_GROUP'} = '';
246$proxysettings{'NCSA_PASS'} = '';
247$proxysettings{'NCSA_PASS_CONFIRM'} = '';
248$proxysettings{'LDAP_BASEDN'} = '';
249$proxysettings{'LDAP_TYPE'} = 'ADS';
250$proxysettings{'LDAP_SERVER'} = '';
251$proxysettings{'LDAP_PORT'} = '389';
252$proxysettings{'LDAP_BINDDN_USER'} = '';
253$proxysettings{'LDAP_BINDDN_PASS'} = '';
254$proxysettings{'LDAP_GROUP'} = '';
b5674643 255$proxysettings{'NTLM_AUTH_GROUP'} = '';
2fc5124b 256$proxysettings{'NTLM_AUTH_BASIC'} = 'off';
ed38f89d
MT
257$proxysettings{'NTLM_DOMAIN'} = '';
258$proxysettings{'NTLM_PDC'} = '';
259$proxysettings{'NTLM_BDC'} = '';
260$proxysettings{'NTLM_ENABLE_ACL'} = 'off';
261$proxysettings{'NTLM_USER_ACL'} = 'positive';
262$proxysettings{'RADIUS_SERVER'} = '';
363fb6af 263$proxysettings{'RADIUS_PORT'} = '1812';
ed38f89d
MT
264$proxysettings{'RADIUS_IDENTIFIER'} = '';
265$proxysettings{'RADIUS_SECRET'} = '';
266$proxysettings{'RADIUS_ENABLE_ACL'} = 'off';
267$proxysettings{'RADIUS_USER_ACL'} = 'positive';
268$proxysettings{'IDENT_REQUIRED'} = 'off';
269$proxysettings{'IDENT_TIMEOUT'} = '10';
270$proxysettings{'IDENT_ENABLE_ACL'} = 'off';
271$proxysettings{'IDENT_USER_ACL'} = 'positive';
9fb25b1c
MT
272$proxysettings{'ENABLE_FILTER'} = 'off';
273$proxysettings{'ENABLE_UPDXLRATOR'} = 'off';
d12aede7 274$proxysettings{'ENABLE_CLAMAV'} = 'off';
ed38f89d
MT
275
276$ncsa_buttontext = $Lang::tr{'advproxy NCSA create user'};
ac1cfefa
MT
277
278&Header::getcgihash(\%proxysettings);
279
ed38f89d
MT
280if ($proxysettings{'THROTTLING_GREEN_TOTAL'} eq 0) {$proxysettings{'THROTTLING_GREEN_TOTAL'} = 'unlimited';}
281if ($proxysettings{'THROTTLING_GREEN_HOST'} eq 0) {$proxysettings{'THROTTLING_GREEN_HOST'} = 'unlimited';}
282if ($proxysettings{'THROTTLING_BLUE_TOTAL'} eq 0) {$proxysettings{'THROTTLING_BLUE_TOTAL'} = 'unlimited';}
283if ($proxysettings{'THROTTLING_BLUE_HOST'} eq 0) {$proxysettings{'THROTTLING_BLUE_HOST'} = 'unlimited';}
ac1cfefa 284
ed38f89d 285if ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy NCSA user management'})
ac1cfefa 286{
ed38f89d
MT
287 $proxysettings{'NCSA_EDIT_MODE'} = 'yes';
288}
289
290if ($proxysettings{'ACTION'} eq $Lang::tr{'add'})
291{
292 $proxysettings{'NCSA_EDIT_MODE'} = 'yes';
293 if (length($proxysettings{'NCSA_PASS'}) < $proxysettings{'NCSA_MIN_PASS_LEN'}) {
294 $errormessage = $Lang::tr{'advproxy errmsg password length 1'}.$proxysettings{'NCSA_MIN_PASS_LEN'}.$Lang::tr{'advproxy errmsg password length 2'};
295 }
296 if (!($proxysettings{'NCSA_PASS'} eq $proxysettings{'NCSA_PASS_CONFIRM'})) {
297 $errormessage = $Lang::tr{'advproxy errmsg passwords different'};
298 }
299 if ($proxysettings{'NCSA_USERNAME'} eq '') {
300 $errormessage = $Lang::tr{'advproxy errmsg no username'};
301 }
302 if (!$errormessage) {
303 $proxysettings{'NCSA_USERNAME'} =~ tr/A-Z/a-z/;
304 &adduser($proxysettings{'NCSA_USERNAME'}, $proxysettings{'NCSA_PASS'}, $proxysettings{'NCSA_GROUP'});
305 }
306 $proxysettings{'NCSA_USERNAME'} = '';
307 $proxysettings{'NCSA_GROUP'} = '';
308 $proxysettings{'NCSA_PASS'} = '';
309 $proxysettings{'NCSA_PASS_CONFIRM'} = '';
310}
ac1cfefa 311
ed38f89d
MT
312if ($proxysettings{'ACTION'} eq $Lang::tr{'remove'})
313{
314 $proxysettings{'NCSA_EDIT_MODE'} = 'yes';
315 &deluser($proxysettings{'ID'});
316}
317
9fb25b1c
MT
318$checked{'ENABLE_UPDXLRATOR'}{'off'} = '';
319$checked{'ENABLE_UPDXLRATOR'}{'on'} = '';
320$checked{'ENABLE_UPDXLRATOR'}{$proxysettings{'ENABLE_UPDXLRATOR'}} = "checked='checked'";
321
ed38f89d
MT
322if ($proxysettings{'ACTION'} eq $Lang::tr{'edit'})
323{
324 $proxysettings{'NCSA_EDIT_MODE'} = 'yes';
325 $ncsa_buttontext = $Lang::tr{'advproxy NCSA update user'};
326 @temp = split(/:/,$proxysettings{'ID'});
327 $proxysettings{'NCSA_USERNAME'} = $temp[0];
328 $proxysettings{'NCSA_GROUP'} = $temp[1];
329 $proxysettings{'NCSA_PASS'} = "lEaVeAlOnE";
330 $proxysettings{'NCSA_PASS_CONFIRM'} = $proxysettings{'NCSA_PASS'};
331}
332
fe1656d2 333if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'}) || ($proxysettings{'ACTION'} eq $Lang::tr{'proxy reconfigure'}))
28c9dec6
CS
334{
335 if ($proxysettings{'ENABLE'} !~ /^(on|off)$/ ||
336 $proxysettings{'TRANSPARENT'} !~ /^(on|off)$/ ||
337 $proxysettings{'ENABLE_BLUE'} !~ /^(on|off)$/ ||
ac1cfefa
MT
338 $proxysettings{'TRANSPARENT_BLUE'} !~ /^(on|off)$/ ) {
339 $errormessage = $Lang::tr{'invalid input'};
340 goto ERROR;
28c9dec6 341 }
8b6f424c 342 if($proxysettings{'CACHE_MEM'} > $proxysettings{'CACHE_SIZE'} && $proxysettings{'CACHE_SIZE'} > 0){
d5a7ff95
AM
343 $errormessage = $Lang::tr{'advproxy errmsg cache'}." ".$proxysettings{'CACHE_MEM'}." > ".$proxysettings{'CACHE_SIZE'};
344 goto ERROR;
345 }
c4b12981 346
f2fdd0c1 347 if (!(&General::validport($proxysettings{'PROXY_PORT'})))
363fb6af
MT
348 {
349 $errormessage = $Lang::tr{'advproxy errmsg invalid proxy port'};
350 goto ERROR;
351 }
0f6b6067
MT
352 if (!(&General::validport($proxysettings{'TRANSPARENT_PORT'})))
353 {
354 $errormessage = $Lang::tr{'advproxy errmsg invalid proxy port'};
355 goto ERROR;
356 }
357 if ($proxysettings{'PROXY_PORT'} eq $proxysettings{'TRANSPARENT_PORT'}) {
358 $errormessage = $Lang::tr{'advproxy errmsg proxy ports equal'};
359 goto ERROR;
360 }
dcfc6334
SS
361 if (!($proxysettings{'UPSTREAM_PROXY'} eq ''))
362 {
363 my @temp = split(/:/,$proxysettings{'UPSTREAM_PROXY'});
364 if (!(&General::validip($temp[0])))
365 {
366 if (!(&General::validdomainname($temp[0])))
367 {
368 $errormessage = $Lang::tr{'advproxy errmsg invalid upstream proxy'};
369 goto ERROR;
370 }
371 }
69491545 372 }
ac1cfefa
MT
373 if (!($proxysettings{'CACHE_SIZE'} =~ /^\d+/) ||
374 ($proxysettings{'CACHE_SIZE'} < 10))
375 {
488d1b7c
CS
376 if (!($proxysettings{'CACHE_SIZE'} eq '0'))
377 {
378 $errormessage = $Lang::tr{'advproxy errmsg hdd cache size'};
379 goto ERROR;
380 }
ed38f89d 381 }
fe1656d2 382 if (!($proxysettings{'FILEDESCRIPTORS'} =~ /^\d+/) ||
4f160f04 383 ($proxysettings{'FILEDESCRIPTORS'} < 1) || ($proxysettings{'FILEDESCRIPTORS'} > 1048576))
fe1656d2
CS
384 {
385 $errormessage = $Lang::tr{'proxy errmsg filedescriptors'};
386 goto ERROR;
387 }
53d67554 388 if (!($proxysettings{'CACHE_MEM'} =~ /^\d+/))
ed38f89d
MT
389 {
390 $errormessage = $Lang::tr{'advproxy errmsg mem cache size'};
ac1cfefa 391 goto ERROR;
28c9dec6 392 }
87504199 393 my @free = &General::system_output("/usr/bin/free");
ed38f89d
MT
394 $free[1] =~ m/(\d+)/;
395 $cachemem = int $1 / 2048;
396 if ($proxysettings{'CACHE_MEM'} > $cachemem) {
397 $proxysettings{'CACHE_MEM'} = $cachemem;
398 }
ac1cfefa
MT
399 if (!($proxysettings{'MAX_SIZE'} =~ /^\d+/))
400 {
401 $errormessage = $Lang::tr{'invalid maximum object size'};
402 goto ERROR;
403 }
404 if (!($proxysettings{'MIN_SIZE'} =~ /^\d+/))
405 {
406 $errormessage = $Lang::tr{'invalid minimum object size'};
407 goto ERROR;
408 }
409 if (!($proxysettings{'MAX_OUTGOING_SIZE'} =~ /^\d+/))
410 {
411 $errormessage = $Lang::tr{'invalid maximum outgoing size'};
412 goto ERROR;
413 }
ed38f89d
MT
414 if (!($proxysettings{'TIME_TO_HOUR'}.$proxysettings{'TIME_TO_MINUTE'} gt $proxysettings{'TIME_FROM_HOUR'}.$proxysettings{'TIME_FROM_MINUTE'}))
415 {
416 $errormessage = $Lang::tr{'advproxy errmsg time restriction'};
417 goto ERROR;
418 }
ac1cfefa
MT
419 if (!($proxysettings{'MAX_INCOMING_SIZE'} =~ /^\d+/))
420 {
421 $errormessage = $Lang::tr{'invalid maximum incoming size'};
422 goto ERROR;
423 }
bb5ca283
PM
424 if (($proxysettings{'ASNBL_FASTFLUX_DETECTION'} eq 'on') || ($proxysettings{'ASNBL_SELECANN_DETECTION'} eq 'on'))
425 {
426 if (-z $proxysettings{'ASNBL_FASTFLUX_THRESHOLD'}) {
427 $errormessage = $Lang::tr{'advproxy fastflux no threshold given'};
428 goto ERROR;
429 }
430 if (! looks_like_number($proxysettings{'ASNBL_FASTFLUX_THRESHOLD'})) {
431 $errormessage = $Lang::tr{'advproxy fastflux threshold invalid'};
432 goto ERROR;
433 }
434 if (($proxysettings{'ASNBL_FASTFLUX_THRESHOLD'} < 2) || ($proxysettings{'ASNBL_FASTFLUX_THRESHOLD'} > 10)) {
435 $errormessage = $Lang::tr{'advproxy fastflux threshold out of bounds'};
436 goto ERROR;
437 }
438 }
ed38f89d
MT
439 if (!($proxysettings{'AUTH_METHOD'} eq 'none'))
440 {
363fb6af 441 unless (($proxysettings{'AUTH_METHOD'} eq 'ident') &&
ed38f89d
MT
442 ($proxysettings{'IDENT_REQUIRED'} eq 'off') &&
443 ($proxysettings{'IDENT_ENABLE_ACL'} eq 'off'))
444 {
445 if ($netsettings{'BLUE_DEV'})
363fb6af 446 {
ed38f89d
MT
447 if ((($proxysettings{'ENABLE'} eq 'off') || ($proxysettings{'TRANSPARENT'} eq 'on')) &&
448 (($proxysettings{'ENABLE_BLUE'} eq 'off') || ($proxysettings{'TRANSPARENT_BLUE'} eq 'on')))
449 {
450 $errormessage = $Lang::tr{'advproxy errmsg non-transparent proxy required'};
451 goto ERROR;
452 }
453 } else {
454 if (($proxysettings{'ENABLE'} eq 'off') || ($proxysettings{'TRANSPARENT'} eq 'on'))
455 {
456 $errormessage = $Lang::tr{'advproxy errmsg non-transparent proxy required'};
457 goto ERROR;
458 }
459 }
460 }
0f8251fe
PM
461 if ((!($proxysettings{'AUTH_MAX_USERIP'} eq '')) &&
462 ((!($proxysettings{'AUTH_MAX_USERIP'} =~ /^\d+/)) || ($proxysettings{'AUTH_MAX_USERIP'} < 1) || ($proxysettings{'AUTH_MAX_USERIP'} > 255)))
463 {
464 $errormessage = $Lang::tr{'advproxy errmsg max userip'};
465 goto ERROR;
466 }
ed38f89d
MT
467 if (!($proxysettings{'AUTH_CACHE_TTL'} =~ /^\d+/))
468 {
469 $errormessage = $Lang::tr{'advproxy errmsg auth cache ttl'};
470 goto ERROR;
471 }
0f8251fe 472 if (!($proxysettings{'AUTH_IPCACHE_TTL'} =~ /^\d+/))
ed38f89d 473 {
0f8251fe 474 $errormessage = $Lang::tr{'advproxy errmsg auth ipcache ttl'};
ed38f89d
MT
475 goto ERROR;
476 }
0f8251fe 477 if ((!($proxysettings{'AUTH_MAX_USERIP'} eq '')) && ($proxysettings{'AUTH_IPCACHE_TTL'} eq '0'))
ed38f89d
MT
478 {
479 $errormessage = $Lang::tr{'advproxy errmsg auth ipcache may not be null'};
480 goto ERROR;
481 }
482 if ((!($proxysettings{'AUTH_CHILDREN'} =~ /^\d+/)) || ($proxysettings{'AUTH_CHILDREN'} < 1) || ($proxysettings{'AUTH_CHILDREN'} > 255))
483 {
484 $errormessage = $Lang::tr{'advproxy errmsg auth children'};
485 goto ERROR;
486 }
487 }
488 if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
489 {
490 if ((!($proxysettings{'NCSA_MIN_PASS_LEN'} =~ /^\d+/)) || ($proxysettings{'NCSA_MIN_PASS_LEN'} < 1) || ($proxysettings{'NCSA_MIN_PASS_LEN'} > 255))
491 {
492 $errormessage = $Lang::tr{'advproxy errmsg password length'};
493 goto ERROR;
494 }
495 }
496 if ($proxysettings{'AUTH_METHOD'} eq 'ident')
497 {
498 if ((!($proxysettings{'IDENT_TIMEOUT'} =~ /^\d+/)) || ($proxysettings{'IDENT_TIMEOUT'} < 1))
499 {
500 $errormessage = $Lang::tr{'advproxy errmsg ident timeout'};
501 goto ERROR;
502 }
503 }
504 if ($proxysettings{'AUTH_METHOD'} eq 'ldap')
505 {
506 if ($proxysettings{'LDAP_BASEDN'} eq '')
507 {
508 $errormessage = $Lang::tr{'advproxy errmsg ldap base dn'};
509 goto ERROR;
510 }
511 if (!&General::validip($proxysettings{'LDAP_SERVER'}))
512 {
e201b6d5
SS
513 if (!&General::validdomainname($proxysettings{'LDAP_SERVER'}))
514 {
515 $errormessage = $Lang::tr{'advproxy errmsg ldap server'};
516 goto ERROR;
517 }
ed38f89d
MT
518 }
519 if (!&General::validport($proxysettings{'LDAP_PORT'}))
520 {
521 $errormessage = $Lang::tr{'advproxy errmsg ldap port'};
522 goto ERROR;
523 }
524 if (($proxysettings{'LDAP_TYPE'} eq 'ADS') || ($proxysettings{'LDAP_TYPE'} eq 'NDS'))
525 {
526 if (($proxysettings{'LDAP_BINDDN_USER'} eq '') || ($proxysettings{'LDAP_BINDDN_PASS'} eq ''))
527 {
528 $errormessage = $Lang::tr{'advproxy errmsg ldap bind dn'};
529 goto ERROR;
530 }
531 }
532 }
ed38f89d
MT
533 if ($proxysettings{'AUTH_METHOD'} eq 'radius')
534 {
535 if (!&General::validip($proxysettings{'RADIUS_SERVER'}))
536 {
537 $errormessage = $Lang::tr{'advproxy errmsg radius server'};
538 goto ERROR;
539 }
540 if (!&General::validport($proxysettings{'RADIUS_PORT'}))
541 {
542 $errormessage = $Lang::tr{'advproxy errmsg radius port'};
543 goto ERROR;
544 }
545 if ($proxysettings{'RADIUS_SECRET'} eq '')
546 {
547 $errormessage = $Lang::tr{'advproxy errmsg radius secret'};
548 goto ERROR;
549 }
ac1cfefa
MT
550 }
551
363fb6af
MT
552 # Quick parent proxy error checking of username and password info. If username password don't both exist give an error.
553 $proxy1 = 'YES';
554 $proxy2 = 'YES';
555 if (($proxysettings{'UPSTREAM_USER'} eq '')) {$proxy1 = '';}
556 if (($proxysettings{'UPSTREAM_PASSWORD'} eq '')) {$proxy2 = '';}
557 if ($proxysettings{'UPSTREAM_USER'} eq 'PASS') {$proxy1=$proxy2='PASS'; $proxysettings{'UPSTREAM_PASSWORD'} = '';}
558 if (($proxy1 ne $proxy2))
559 {
560 $errormessage = $Lang::tr{'advproxy errmsg invalid upstream proxy username or password setting'};
561 goto ERROR;
562 }
ac1cfefa 563
ed38f89d
MT
564ERROR:
565 &check_acls;
ac1cfefa 566
ed38f89d
MT
567 if ($errormessage) {
568 $proxysettings{'VALID'} = 'no'; }
569 else {
363fb6af 570 $proxysettings{'VALID'} = 'yes'; }
ac1cfefa 571
ed38f89d 572 if ($proxysettings{'VALID'} eq 'yes')
ac1cfefa 573 {
e698090e
SS
574 # Determine if suricata may needs to be restarted.
575 my $suricata_proxy_ports_changed;
576
577 # Check if the IDS is running
578 if(&IDS::ids_is_running()) {
579 my %oldproxysettings;
580
581 # Read-in current proxy settings and store them as oldsettings hash.
582 &General::readhash("${General::swroot}/proxy/advanced/settings", \%oldproxysettings);
583
584 # Check if the proxy port has been changed.
585 unless ($proxysettings{'PROXY_PORT'} eq $oldproxysettings{'PROXY_PORT'}) {
586 # Port has changed, suricata needs to be adjusted.
587 $suricata_proxy_ports_changed = 1;
588 }
589
590 # Check if the transparent port has been changed.
591 unless ($proxysettings{'TRANSPARENT_PORT'} eq $oldproxysettings{'TRANSPARENT_PORT'}) {
592 # Transparent port has changed, suricata needs to be adjusted.
593 $suricata_proxy_ports_changed = 1;
594 }
595 }
596
ed38f89d 597 &write_acls;
ac1cfefa 598
ed38f89d
MT
599 delete $proxysettings{'SRC_SUBNETS'};
600 delete $proxysettings{'SRC_BANNED_IP'};
601 delete $proxysettings{'SRC_BANNED_MAC'};
602 delete $proxysettings{'SRC_UNRESTRICTED_IP'};
603 delete $proxysettings{'SRC_UNRESTRICTED_MAC'};
604 delete $proxysettings{'DST_NOCACHE'};
605 delete $proxysettings{'DST_NOAUTH'};
ce1c170b
AK
606 delete $proxysettings{'DST_NOPROXY_IP'};
607 delete $proxysettings{'DST_NOPROXY_URL'};
363fb6af
MT
608 delete $proxysettings{'PORTS_SAFE'};
609 delete $proxysettings{'PORTS_SSL'};
ed38f89d
MT
610 delete $proxysettings{'MIME_TYPES'};
611 delete $proxysettings{'NTLM_ALLOW_USERS'};
612 delete $proxysettings{'NTLM_DENY_USERS'};
613 delete $proxysettings{'RADIUS_ALLOW_USERS'};
614 delete $proxysettings{'RADIUS_DENY_USERS'};
615 delete $proxysettings{'IDENT_HOSTS'};
616 delete $proxysettings{'IDENT_ALLOW_USERS'};
617 delete $proxysettings{'IDENT_DENY_USERS'};
ac1cfefa 618
ed38f89d
MT
619 delete $proxysettings{'CRE_GROUPS'};
620 delete $proxysettings{'CRE_SVHOSTS'};
ac1cfefa 621
ed38f89d
MT
622 delete $proxysettings{'NCSA_USERNAME'};
623 delete $proxysettings{'NCSA_GROUP'};
624 delete $proxysettings{'NCSA_PASS'};
625 delete $proxysettings{'NCSA_PASS_CONFIRM'};
ac1cfefa 626
ed38f89d
MT
627 $proxysettings{'TIME_MON'} = 'off' unless exists $proxysettings{'TIME_MON'};
628 $proxysettings{'TIME_TUE'} = 'off' unless exists $proxysettings{'TIME_TUE'};
629 $proxysettings{'TIME_WED'} = 'off' unless exists $proxysettings{'TIME_WED'};
630 $proxysettings{'TIME_THU'} = 'off' unless exists $proxysettings{'TIME_THU'};
631 $proxysettings{'TIME_FRI'} = 'off' unless exists $proxysettings{'TIME_FRI'};
632 $proxysettings{'TIME_SAT'} = 'off' unless exists $proxysettings{'TIME_SAT'};
633 $proxysettings{'TIME_SUN'} = 'off' unless exists $proxysettings{'TIME_SUN'};
ac1cfefa 634
ed38f89d
MT
635 $proxysettings{'AUTH_ALWAYS_REQUIRED'} = 'off' unless exists $proxysettings{'AUTH_ALWAYS_REQUIRED'};
636 $proxysettings{'NTLM_ENABLE_INT_AUTH'} = 'off' unless exists $proxysettings{'NTLM_ENABLE_INT_AUTH'};
ac1cfefa 637
ed38f89d 638 &General::writehash("${General::swroot}/proxy/advanced/settings", \%proxysettings);
ac1cfefa 639
363fb6af
MT
640 if (-e "${General::swroot}/proxy/settings") { &General::readhash("${General::swroot}/proxy/settings", \%stdproxysettings); }
641 $stdproxysettings{'PROXY_PORT'} = $proxysettings{'PROXY_PORT'};
488d1b7c
CS
642 $stdproxysettings{'UPSTREAM_PROXY'} = $proxysettings{'UPSTREAM_PROXY'};
643 $stdproxysettings{'UPSTREAM_USER'} = $proxysettings{'UPSTREAM_USER'};
644 $stdproxysettings{'UPSTREAM_PASSWORD'} = $proxysettings{'UPSTREAM_PASSWORD'};
9fb25b1c
MT
645 $stdproxysettings{'ENABLE_FILTER'} = $proxysettings{'ENABLE_FILTER'};
646 $stdproxysettings{'ENABLE_UPDXLRATOR'} = $proxysettings{'ENABLE_UPDXLRATOR'};
d12aede7 647 $stdproxysettings{'ENABLE_CLAMAV'} = $proxysettings{'ENABLE_CLAMAV'};
363fb6af 648 &General::writehash("${General::swroot}/proxy/settings", \%stdproxysettings);
ac1cfefa 649
ed38f89d
MT
650 &writeconfig;
651 &writepacfile;
652
fe1656d2
CS
653 if ($proxysettings{'CACHEMGR'} eq 'on'){&writecachemgr;}
654
66191888 655 &General::system ('/usr/local/bin/squidctrl', 'disable');
ed38f89d
MT
656 unlink "${General::swroot}/proxy/enable";
657 unlink "${General::swroot}/proxy/transparent";
658 unlink "${General::swroot}/proxy/enable_blue";
659 unlink "${General::swroot}/proxy/transparent_blue";
ac1cfefa 660
ac1cfefa 661 if ($proxysettings{'ENABLE'} eq 'on') {
66191888
MT
662 &General::system('/usr/bin/touch', "${General::swroot}/proxy/enable");
663 &General::system('/usr/local/bin/squidctrl', 'enable'); }
6c689591 664 if ($proxysettings{'TRANSPARENT'} eq 'on' && $proxysettings{'ENABLE'} eq 'on') {
66191888 665 &General::system('/usr/bin/touch', "${General::swroot}/proxy/transparent"); }
ac1cfefa 666 if ($proxysettings{'ENABLE_BLUE'} eq 'on') {
66191888
MT
667 &General::system('/usr/bin/touch', "${General::swroot}/proxy/enable_blue");
668 &General::system('/usr/local/bin/squidctrl', 'enable'); }
6c689591 669 if ($proxysettings{'TRANSPARENT_BLUE'} eq 'on' && $proxysettings{'ENABLE_BLUE'} eq 'on') {
66191888 670 &General::system('/usr/bin/touch', "${General::swroot}/proxy/transparent_blue"); }
ed38f89d 671
66191888
MT
672 if ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'}) { &General::system('/usr/local/bin/squidctrl', 'restart'); }
673 if ($proxysettings{'ACTION'} eq $Lang::tr{'proxy reconfigure'}) { &General::system('/usr/local/bin/squidctrl', 'reconfigure'); }
e698090e
SS
674
675 # Check if the suricata_proxy_ports_changed flag has been set.
676 if ($suricata_proxy_ports_changed) {
677 # Re-generate HTTP ports file.
678 &IDS::generate_http_ports_file();
679
680 # Restart suricata.
681 &IDS::call_suricatactrl("restart");
682 }
fe1656d2 683 }
ac1cfefa
MT
684}
685
363fb6af 686if ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy clear cache'})
ac1cfefa 687{
66191888 688 &General::system('/usr/local/bin/squidctrl', 'flush');
ac1cfefa
MT
689}
690
ed38f89d
MT
691if (!$errormessage)
692{
693 if (-e "${General::swroot}/proxy/advanced/settings") {
694 &General::readhash("${General::swroot}/proxy/advanced/settings", \%proxysettings);
695 } elsif (-e "${General::swroot}/proxy/settings") {
696 &General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
697 }
698 &read_acls;
699}
ac1cfefa 700
dfee7582
SS
701# ------------------------------------------------------------------
702
703# Hook to regenerate the configuration files, if cgi got called from command line.
704if ($ENV{"REMOTE_ADDR"} eq "") {
705 writeconfig();
706 exit(0);
707}
708
709# -------------------------------------------------------------------
710
ac1cfefa
MT
711$checked{'ENABLE'}{'off'} = '';
712$checked{'ENABLE'}{'on'} = '';
713$checked{'ENABLE'}{$proxysettings{'ENABLE'}} = "checked='checked'";
714
715$checked{'TRANSPARENT'}{'off'} = '';
716$checked{'TRANSPARENT'}{'on'} = '';
717$checked{'TRANSPARENT'}{$proxysettings{'TRANSPARENT'}} = "checked='checked'";
718
719$checked{'ENABLE_BLUE'}{'off'} = '';
720$checked{'ENABLE_BLUE'}{'on'} = '';
721$checked{'ENABLE_BLUE'}{$proxysettings{'ENABLE_BLUE'}} = "checked='checked'";
722
723$checked{'TRANSPARENT_BLUE'}{'off'} = '';
724$checked{'TRANSPARENT_BLUE'}{'on'} = '';
725$checked{'TRANSPARENT_BLUE'}{$proxysettings{'TRANSPARENT_BLUE'}} = "checked='checked'";
726
ed38f89d
MT
727$checked{'FORWARD_IPADDRESS'}{'off'} = '';
728$checked{'FORWARD_IPADDRESS'}{'on'} = '';
729$checked{'FORWARD_IPADDRESS'}{$proxysettings{'FORWARD_IPADDRESS'}} = "checked='checked'";
730$checked{'FORWARD_USERNAME'}{'off'} = '';
731$checked{'FORWARD_USERNAME'}{'on'} = '';
732$checked{'FORWARD_USERNAME'}{$proxysettings{'FORWARD_USERNAME'}} = "checked='checked'";
733$checked{'FORWARD_VIA'}{'off'} = '';
734$checked{'FORWARD_VIA'}{'on'} = '';
735$checked{'FORWARD_VIA'}{$proxysettings{'FORWARD_VIA'}} = "checked='checked'";
363fb6af
MT
736$checked{'NO_CONNECTION_AUTH'}{'off'} = '';
737$checked{'NO_CONNECTION_AUTH'}{'on'} = '';
738$checked{'NO_CONNECTION_AUTH'}{$proxysettings{'NO_CONNECTION_AUTH'}} = "checked='checked'";
ed38f89d
MT
739
740$selected{'MEM_POLICY'}{$proxysettings{'MEM_POLICY'}} = "selected='selected'";
741$selected{'CACHE_POLICY'}{$proxysettings{'CACHE_POLICY'}} = "selected='selected'";
742$selected{'L1_DIRS'}{$proxysettings{'L1_DIRS'}} = "selected='selected'";
743$checked{'OFFLINE_MODE'}{'off'} = '';
744$checked{'OFFLINE_MODE'}{'on'} = '';
745$checked{'OFFLINE_MODE'}{$proxysettings{'OFFLINE_MODE'}} = "checked='checked'";
6bea848d
JB
746$checked{'CACHE_DIGESTS'}{'off'} = '';
747$checked{'CACHE_DIGESTS'}{'on'} = '';
748$checked{'CACHE_DIGESTS'}{$proxysettings{'CACHE_DIGESTS'}} = "checked='checked'";
ed38f89d 749
ac1cfefa
MT
750$checked{'LOGGING'}{'off'} = '';
751$checked{'LOGGING'}{'on'} = '';
752$checked{'LOGGING'}{$proxysettings{'LOGGING'}} = "checked='checked'";
fe1656d2
CS
753$checked{'CACHEMGR'}{'off'} = '';
754$checked{'CACHEMGR'}{'on'} = '';
755$checked{'CACHEMGR'}{$proxysettings{'CACHEMGR'}} = "checked='checked'";
ed38f89d
MT
756$checked{'LOGQUERY'}{'off'} = '';
757$checked{'LOGQUERY'}{'on'} = '';
758$checked{'LOGQUERY'}{$proxysettings{'LOGQUERY'}} = "checked='checked'";
759$checked{'LOGUSERAGENT'}{'off'} = '';
760$checked{'LOGUSERAGENT'}{'on'} = '';
761$checked{'LOGUSERAGENT'}{$proxysettings{'LOGUSERAGENT'}} = "checked='checked'";
762
763$selected{'ERR_LANGUAGE'}{$proxysettings{'ERR_LANGUAGE'}} = "selected='selected'";
363fb6af 764$selected{'ERR_DESIGN'}{$proxysettings{'ERR_DESIGN'}} = "selected='selected'";
ed38f89d 765
9fb25b1c
MT
766$checked{'NO_PROXY_LOCAL'}{'off'} = '';
767$checked{'NO_PROXY_LOCAL'}{'on'} = '';
768$checked{'NO_PROXY_LOCAL'}{$proxysettings{'NO_PROXY_LOCAL'}} = "checked='checked'";
769$checked{'NO_PROXY_LOCAL_BLUE'}{'off'} = '';
770$checked{'NO_PROXY_LOCAL_BLUE'}{'on'} = '';
771$checked{'NO_PROXY_LOCAL_BLUE'}{$proxysettings{'NO_PROXY_LOCAL_BLUE'}} = "checked='checked'";
772
ed38f89d
MT
773$checked{'CLASSROOM_EXT'}{'off'} = '';
774$checked{'CLASSROOM_EXT'}{'on'} = '';
775$checked{'CLASSROOM_EXT'}{$proxysettings{'CLASSROOM_EXT'}} = "checked='checked'";
776
777$selected{'TIME_ACCESS_MODE'}{$proxysettings{'TIME_ACCESS_MODE'}} = "selected='selected'";
778$selected{'TIME_FROM_HOUR'}{$proxysettings{'TIME_FROM_HOUR'}} = "selected='selected'";
779$selected{'TIME_FROM_MINUTE'}{$proxysettings{'TIME_FROM_MINUTE'}} = "selected='selected'";
780$selected{'TIME_TO_HOUR'}{$proxysettings{'TIME_TO_HOUR'}} = "selected='selected'";
781$selected{'TIME_TO_MINUTE'}{$proxysettings{'TIME_TO_MINUTE'}} = "selected='selected'";
782
783$proxysettings{'TIME_MON'} = 'on' unless exists $proxysettings{'TIME_MON'};
784$proxysettings{'TIME_TUE'} = 'on' unless exists $proxysettings{'TIME_TUE'};
785$proxysettings{'TIME_WED'} = 'on' unless exists $proxysettings{'TIME_WED'};
786$proxysettings{'TIME_THU'} = 'on' unless exists $proxysettings{'TIME_THU'};
787$proxysettings{'TIME_FRI'} = 'on' unless exists $proxysettings{'TIME_FRI'};
788$proxysettings{'TIME_SAT'} = 'on' unless exists $proxysettings{'TIME_SAT'};
789$proxysettings{'TIME_SUN'} = 'on' unless exists $proxysettings{'TIME_SUN'};
790
791$checked{'TIME_MON'}{'off'} = '';
792$checked{'TIME_MON'}{'on'} = '';
793$checked{'TIME_MON'}{$proxysettings{'TIME_MON'}} = "checked='checked'";
794$checked{'TIME_TUE'}{'off'} = '';
795$checked{'TIME_TUE'}{'on'} = '';
796$checked{'TIME_TUE'}{$proxysettings{'TIME_TUE'}} = "checked='checked'";
797$checked{'TIME_WED'}{'off'} = '';
798$checked{'TIME_WED'}{'on'} = '';
799$checked{'TIME_WED'}{$proxysettings{'TIME_WED'}} = "checked='checked'";
800$checked{'TIME_THU'}{'off'} = '';
801$checked{'TIME_THU'}{'on'} = '';
802$checked{'TIME_THU'}{$proxysettings{'TIME_THU'}} = "checked='checked'";
803$checked{'TIME_FRI'}{'off'} = '';
804$checked{'TIME_FRI'}{'on'} = '';
805$checked{'TIME_FRI'}{$proxysettings{'TIME_FRI'}} = "checked='checked'";
806$checked{'TIME_SAT'}{'off'} = '';
807$checked{'TIME_SAT'}{'on'} = '';
808$checked{'TIME_SAT'}{$proxysettings{'TIME_SAT'}} = "checked='checked'";
809$checked{'TIME_SUN'}{'off'} = '';
810$checked{'TIME_SUN'}{'on'} = '';
811$checked{'TIME_SUN'}{$proxysettings{'TIME_SUN'}} = "checked='checked'";
812
813$selected{'THROTTLING_GREEN_TOTAL'}{$proxysettings{'THROTTLING_GREEN_TOTAL'}} = "selected='selected'";
814$selected{'THROTTLING_GREEN_HOST'}{$proxysettings{'THROTTLING_GREEN_HOST'}} = "selected='selected'";
815$selected{'THROTTLING_BLUE_TOTAL'}{$proxysettings{'THROTTLING_BLUE_TOTAL'}} = "selected='selected'";
816$selected{'THROTTLING_BLUE_HOST'}{$proxysettings{'THROTTLING_BLUE_HOST'}} = "selected='selected'";
817
bb5ca283
PM
818$checked{'ASNBL_FASTFLUX_DETECTION'}{'off'} = '';
819$checked{'ASNBL_FASTFLUX_DETECTION'}{'on'} = '';
820$checked{'ASNBL_FASTFLUX_DETECTION'}{$proxysettings{'ASNBL_FASTFLUX_DETECTION'}} = "checked='checked'";
821
822$checked{'ASNBL_SELECANN_DETECTION'}{'off'} = '';
823$checked{'ASNBL_SELECANN_DETECTION'}{'on'} = '';
824$checked{'ASNBL_SELECANN_DETECTION'}{$proxysettings{'ASNBL_SELECANN_DETECTION'}} = "checked='checked'";
825
ed38f89d
MT
826$checked{'ENABLE_MIME_FILTER'}{'off'} = '';
827$checked{'ENABLE_MIME_FILTER'}{'on'} = '';
828$checked{'ENABLE_MIME_FILTER'}{$proxysettings{'ENABLE_MIME_FILTER'}} = "checked='checked'";
829
ed38f89d
MT
830$checked{'AUTH_METHOD'}{'none'} = '';
831$checked{'AUTH_METHOD'}{'ncsa'} = '';
832$checked{'AUTH_METHOD'}{'ident'} = '';
833$checked{'AUTH_METHOD'}{'ldap'} = '';
603248db 834$checked{'AUTH_METHOD'}{'ntlm-auth'} = '';
ed38f89d
MT
835$checked{'AUTH_METHOD'}{'radius'} = '';
836$checked{'AUTH_METHOD'}{$proxysettings{'AUTH_METHOD'}} = "checked='checked'";
ac1cfefa 837
ed38f89d
MT
838$proxysettings{'AUTH_ALWAYS_REQUIRED'} = 'on' unless exists $proxysettings{'AUTH_ALWAYS_REQUIRED'};
839
840$checked{'AUTH_ALWAYS_REQUIRED'}{'off'} = '';
841$checked{'AUTH_ALWAYS_REQUIRED'}{'on'} = '';
842$checked{'AUTH_ALWAYS_REQUIRED'}{$proxysettings{'AUTH_ALWAYS_REQUIRED'}} = "checked='checked'";
843
844$checked{'NCSA_BYPASS_REDIR'}{'off'} = '';
845$checked{'NCSA_BYPASS_REDIR'}{'on'} = '';
846$checked{'NCSA_BYPASS_REDIR'}{$proxysettings{'NCSA_BYPASS_REDIR'}} = "checked='checked'";
847
848$selected{'NCSA_GROUP'}{$proxysettings{'NCSA_GROUP'}} = "selected='selected'";
849
850$selected{'LDAP_TYPE'}{$proxysettings{'LDAP_TYPE'}} = "selected='selected'";
851
852$proxysettings{'NTLM_ENABLE_INT_AUTH'} = 'on' unless exists $proxysettings{'NTLM_ENABLE_INT_AUTH'};
853
854$checked{'NTLM_ENABLE_INT_AUTH'}{'off'} = '';
855$checked{'NTLM_ENABLE_INT_AUTH'}{'on'} = '';
856$checked{'NTLM_ENABLE_INT_AUTH'}{$proxysettings{'NTLM_ENABLE_INT_AUTH'}} = "checked='checked'";
857
858$checked{'NTLM_ENABLE_ACL'}{'off'} = '';
859$checked{'NTLM_ENABLE_ACL'}{'on'} = '';
860$checked{'NTLM_ENABLE_ACL'}{$proxysettings{'NTLM_ENABLE_ACL'}} = "checked='checked'";
861
862$checked{'NTLM_USER_ACL'}{'positive'} = '';
863$checked{'NTLM_USER_ACL'}{'negative'} = '';
864$checked{'NTLM_USER_ACL'}{$proxysettings{'NTLM_USER_ACL'}} = "checked='checked'";
865
2fc5124b
MT
866$checked{'NTLM_AUTH_BASIC'}{'on'} = '';
867$checked{'NTLM_AUTH_BASIC'}{'off'} = '';
868$checked{'NTLM_AUTH_BASIC'}{$proxysettings{'NTLM_AUTH_BASIC'}} = "checked='checked'";
869
ed38f89d
MT
870$checked{'RADIUS_ENABLE_ACL'}{'off'} = '';
871$checked{'RADIUS_ENABLE_ACL'}{'on'} = '';
872$checked{'RADIUS_ENABLE_ACL'}{$proxysettings{'RADIUS_ENABLE_ACL'}} = "checked='checked'";
873
874$checked{'RADIUS_USER_ACL'}{'positive'} = '';
875$checked{'RADIUS_USER_ACL'}{'negative'} = '';
876$checked{'RADIUS_USER_ACL'}{$proxysettings{'RADIUS_USER_ACL'}} = "checked='checked'";
877
878$checked{'IDENT_REQUIRED'}{'off'} = '';
879$checked{'IDENT_REQUIRED'}{'on'} = '';
880$checked{'IDENT_REQUIRED'}{$proxysettings{'IDENT_REQUIRED'}} = "checked='checked'";
881
882$checked{'IDENT_ENABLE_ACL'}{'off'} = '';
883$checked{'IDENT_ENABLE_ACL'}{'on'} = '';
884$checked{'IDENT_ENABLE_ACL'}{$proxysettings{'IDENT_ENABLE_ACL'}} = "checked='checked'";
885
886$checked{'IDENT_USER_ACL'}{'positive'} = '';
887$checked{'IDENT_USER_ACL'}{'negative'} = '';
888$checked{'IDENT_USER_ACL'}{$proxysettings{'IDENT_USER_ACL'}} = "checked='checked'";
889
9fb25b1c
MT
890$checked{'ENABLE_FILTER'}{'off'} = '';
891$checked{'ENABLE_FILTER'}{'on'} = '';
892$checked{'ENABLE_FILTER'}{$proxysettings{'ENABLE_FILTER'}} = "checked='checked'";
ed38f89d 893
9fb25b1c
MT
894$checked{'ENABLE_UPDXLRATOR'}{'off'} = '';
895$checked{'ENABLE_UPDXLRATOR'}{'on'} = '';
896$checked{'ENABLE_UPDXLRATOR'}{$proxysettings{'ENABLE_UPDXLRATOR'}} = "checked='checked'";
ed38f89d 897
d12aede7
CS
898$checked{'ENABLE_CLAMAV'}{'off'} = '';
899$checked{'ENABLE_CLAMAV'}{'on'} = '';
900$checked{'ENABLE_CLAMAV'}{$proxysettings{'ENABLE_CLAMAV'}} = "checked='checked'";
901
ed38f89d 902&Header::openpage($Lang::tr{'advproxy advanced web proxy configuration'}, 1, '');
ac1cfefa
MT
903
904&Header::openbigbox('100%', 'left', '', $errormessage);
905
906if ($errormessage) {
907 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
908 print "<font class='base'>$errormessage&nbsp;</font>\n";
909 &Header::closebox();
910}
911
363fb6af
MT
912if ($squidversion[0] =~ /^Squid\sCache:\sVersion\s/i)
913{
914 $squidversion[0] =~ s/^Squid\sCache:\sVersion//i;
915 $squidversion[0] =~ s/^\s+//g;
916 $squidversion[0] =~ s/\s+$//g;
917} else {
918 $squidversion[0] = $Lang::tr{'advproxy unknown'};
919}
920
ed38f89d
MT
921# ===================================================================
922# Main settings
923# ===================================================================
924
925unless ($proxysettings{'NCSA_EDIT_MODE'} eq 'yes') {
926
ac1cfefa
MT
927print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
928
ed38f89d
MT
929&Header::openbox('100%', 'left', "$Lang::tr{'advproxy advanced web proxy'}");
930
ac1cfefa
MT
931print <<END
932<table width='100%'>
933<tr>
ed38f89d
MT
934 <td colspan='4' class='base'><b>$Lang::tr{'advproxy common settings'}</b></td>
935</tr>
936<tr>
937 <td width='25%' class='base'>$Lang::tr{'advproxy enabled on'} <font color="$Header::colourgreen">Green</font>:</td>
938 <td width='20%'><input type='checkbox' name='ENABLE' $checked{'ENABLE'}{'on'} /></td>
e3edceeb 939 <td width='25%' class='base'>$Lang::tr{'advproxy proxy port'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
ed38f89d 940 <td width='30%'><input type='text' name='PROXY_PORT' value='$proxysettings{'PROXY_PORT'}' size='5' /></td>
ac1cfefa
MT
941</tr>
942<tr>
ed38f89d 943 <td class='base'>$Lang::tr{'advproxy transparent on'} <font color="$Header::colourgreen">Green</font>:</td>
ac1cfefa 944 <td><input type='checkbox' name='TRANSPARENT' $checked{'TRANSPARENT'}{'on'} /></td>
e3edceeb 945 <td width='25%' class='base'>$Lang::tr{'advproxy proxy port transparent'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
0f6b6067 946 <td width='30%'><input type='text' name='TRANSPARENT_PORT' value='$proxysettings{'TRANSPARENT_PORT'}' size='5' /></td>
ac1cfefa
MT
947</tr>
948<tr>
949END
950;
951if ($netsettings{'BLUE_DEV'}) {
ed38f89d 952 print "<td class='base'>$Lang::tr{'advproxy enabled on'} <font color='$Header::colourblue'>Blue</font>:</td>";
ac1cfefa
MT
953 print "<td><input type='checkbox' name='ENABLE_BLUE' $checked{'ENABLE_BLUE'}{'on'} /></td>";
954} else {
955 print "<td colspan='2'>&nbsp;</td>";
956}
957print <<END
e3edceeb 958 <td class='base'>$Lang::tr{'advproxy visible hostname'}:</td>
0f6b6067 959 <td><input type='text' name='VISIBLE_HOSTNAME' value='$proxysettings{'VISIBLE_HOSTNAME'}' /></td>
ac1cfefa
MT
960</tr>
961<tr>
962END
963;
964if ($netsettings{'BLUE_DEV'}) {
ed38f89d 965 print "<td class='base'>$Lang::tr{'advproxy transparent on'} <font color='$Header::colourblue'>Blue</font>:</td>";
ac1cfefa
MT
966 print "<td><input type='checkbox' name='TRANSPARENT_BLUE' $checked{'TRANSPARENT_BLUE'}{'on'} /></td>";
967} else {
968 print "<td colspan='2'>&nbsp;</td>";
969}
970print <<END
ed38f89d
MT
971 <td class='base'>$Lang::tr{'advproxy error language'}:</td>
972 <td class='base'>
973 <select name='ERR_LANGUAGE'>
974END
975;
363fb6af 976 foreach (<$errordir/*>) {
ed38f89d
MT
977 if (-d) {
978 $language = substr($_,rindex($_,"/")+1);
979 print "<option value='$language' $selected{'ERR_LANGUAGE'}{$language}>$language</option>\n";
980 }
981 }
982print <<END
983 </select>
984 </td>
985</tr>
10e4f239 986<tr>
13aeb192
PM
987 <td>&nbsp;</td>
988 <td>&nbsp;</td>
363fb6af
MT
989 <td class='base'>$Lang::tr{'advproxy error design'}:</td>
990 <td class='base'><select name='ERR_DESIGN'>
0d948999 991 <option value='ipfire' $selected{'ERR_DESIGN'}{'ipfire'}>IPFire</option>
363fb6af
MT
992 <option value='squid' $selected{'ERR_DESIGN'}{'squid'}>$Lang::tr{'advproxy standard'}</option>
993 </select></td>
10e4f239 994</tr>
ed38f89d
MT
995</table>
996<hr size='1'>
997<table width='100%'>
d12aede7
CS
998END
999;
1000if ( -e "/usr/bin/squidclamav" ) {
01212e04 1001 print "<td class='base'><b>".$Lang::tr{'advproxy squidclamav'}."</b><br />";
bd027d94
CS
1002 if ( ! -e "/var/run/clamav/clamd.pid" ){
1003 print "<font color='red'>clamav not running</font><br /><br />";
1004 $proxysettings{'ENABLE_CLAMAV'} = 'off';
1005 }
1006 else {
1007 print $Lang::tr{'advproxy enabled'}."<input type='checkbox' name='ENABLE_CLAMAV' ".$checked{'ENABLE_CLAMAV'}{'on'}." /><br />";
1a3323f2 1008}
01212e04
CS
1009 print "</td>";
1010} else {
1011 print "<td></td>";
d12aede7 1012}
082771c1 1013print "<td class='base'><a href='/cgi-bin/urlfilter.cgi'><b>".$Lang::tr{'advproxy url filter'}."</a></b><br />";
01212e04 1014print $Lang::tr{'advproxy enabled'}."<input type='checkbox' name='ENABLE_FILTER' ".$checked{'ENABLE_FILTER'}{'on'}." /><br />";
01212e04 1015print "</td>";
082771c1 1016print "<td class='base'><a href='/cgi-bin/updatexlrator.cgi'><b>".$Lang::tr{'advproxy update accelerator'}."</a></b><br />";
01212e04 1017print $Lang::tr{'advproxy enabled'}."<input type='checkbox' name='ENABLE_UPDXLRATOR' ".$checked{'ENABLE_UPDXLRATOR'}{'on'}." /><br />";
01212e04 1018print "</td></tr>";
d12aede7 1019print <<END
9141bd34
CS
1020</table>
1021<hr size='1'>
1022<table width='100%'>
ed38f89d
MT
1023<tr>
1024 <td colspan='4' class='base'><b>$Lang::tr{'advproxy upstream proxy'}</b></td>
1025</tr>
1026<tr>
488d1b7c
CS
1027 <td width='25%' class='base'>$Lang::tr{'advproxy via forwarding'}:</td>
1028 <td width='20%'><input type='checkbox' name='FORWARD_VIA' $checked{'FORWARD_VIA'}{'on'} /></td>
e3edceeb 1029 <td width='25%' class='base'>$Lang::tr{'advproxy upstream proxy host:port'}:</td>
488d1b7c 1030 <td width='30%'><input type='text' name='UPSTREAM_PROXY' value='$proxysettings{'UPSTREAM_PROXY'}' /></td>
ed38f89d
MT
1031</tr>
1032<tr>
488d1b7c
CS
1033 <td class='base'>$Lang::tr{'advproxy client IP forwarding'}:</td>
1034 <td><input type='checkbox' name='FORWARD_IPADDRESS' $checked{'FORWARD_IPADDRESS'}{'on'} /></td>
e3edceeb 1035 <td class='base'>$Lang::tr{'advproxy upstream username'}:</td>
488d1b7c 1036 <td><input type='text' name='UPSTREAM_USER' value='$proxysettings{'UPSTREAM_USER'}' /></td>
ac1cfefa 1037</tr>
ac1cfefa 1038<tr>
488d1b7c
CS
1039 <td class='base'>$Lang::tr{'advproxy username forwarding'}:</td>
1040 <td><input type='checkbox' name='FORWARD_USERNAME' $checked{'FORWARD_USERNAME'}{'on'} /></td>
e3edceeb 1041 <td class='base'>$Lang::tr{'advproxy upstream password'}:</td>
488d1b7c 1042 <td><input type='password' name='UPSTREAM_PASSWORD' value='$proxysettings{'UPSTREAM_PASSWORD'}' /></td>
ed38f89d 1043</tr>
363fb6af 1044<tr>
488d1b7c
CS
1045 <td class='base'>$Lang::tr{'advproxy no connection auth'}:</td>
1046 <td><input type='checkbox' name='NO_CONNECTION_AUTH' $checked{'NO_CONNECTION_AUTH'}{'on'} /></td>
1047 <td>&nbsp;</td>
1048 <td>&nbsp;</td>
363fb6af 1049</tr>
ed38f89d
MT
1050</table>
1051<hr size='1'>
1052<table width='100%'>
1053<tr>
1054 <td colspan='4' class='base'><b>$Lang::tr{'advproxy log settings'}</b></td>
1055</tr>
1056<tr>
488d1b7c
CS
1057 <td width='25%' class='base'>$Lang::tr{'advproxy log enabled'}:</td>
1058 <td width='20%'><input type='checkbox' name='LOGGING' $checked{'LOGGING'}{'on'} /></td>
1059 <td width='25%'class='base'>$Lang::tr{'advproxy log query'}:</td>
1060 <td width='30%'><input type='checkbox' name='LOGQUERY' $checked{'LOGQUERY'}{'on'} /></td>
1061</tr>
1062<tr>
1063 <td>&nbsp;</td>
1064 <td>&nbsp;</td>
1065 <td class='base'>$Lang::tr{'advproxy log useragent'}:</td>
1066 <td><input type='checkbox' name='LOGUSERAGENT' $checked{'LOGUSERAGENT'}{'on'} /></td>
ed38f89d
MT
1067</tr>
1068</table>
1069<hr size='1'>
1070<table width='100%'>
1071<tr>
1072 <td colspan='4'><b>$Lang::tr{'advproxy cache management'}</b></td>
1073</tr>
fe1656d2 1074<tr>
c4b12981 1075 <td class='base'><a href='/cgi-bin/cachemgr.cgi' target='_blank'>$Lang::tr{'proxy cachemgr'}:</td>
fe1656d2 1076 <td><input type='checkbox' name='CACHEMGR' $checked{'CACHEMGR'}{'on'} /></td>
e3edceeb 1077 <td class='base'>$Lang::tr{'advproxy admin mail'}:</td>
fe1656d2
CS
1078 <td><input type='text' name='ADMIN_MAIL_ADDRESS' value='$proxysettings{'ADMIN_MAIL_ADDRESS'}' /></td>
1079</tr>
1080<tr>
e3edceeb 1081 <td class='base'>$Lang::tr{'proxy filedescriptors'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
fe1656d2 1082 <td><input type='text' name='FILEDESCRIPTORS' value='$proxysettings{'FILEDESCRIPTORS'}' size='5' /></td>
e3edceeb 1083 <td class='base'>$Lang::tr{'proxy admin password'}:</td>
fe1656d2
CS
1084 <td><input type='text' name='ADMIN_PASSWORD' value='$proxysettings{'ADMIN_PASSWORD'}' /></td>
1085</tr>
ed38f89d 1086<tr>
488d1b7c 1087 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
ac1cfefa
MT
1088</tr>
1089<tr>
e3edceeb 1090 <td class='base'>$Lang::tr{'advproxy ram cache size'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
ed38f89d 1091 <td><input type='text' name='CACHE_MEM' value='$proxysettings{'CACHE_MEM'}' size='5' /></td>
e3edceeb 1092 <td class='base'>$Lang::tr{'advproxy hdd cache size'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
ac1cfefa
MT
1093 <td><input type='text' name='CACHE_SIZE' value='$proxysettings{'CACHE_SIZE'}' size='5' /></td>
1094</tr>
1095<tr>
e3edceeb 1096 <td class='base'>$Lang::tr{'advproxy min size'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
ac1cfefa 1097 <td><input type='text' name='MIN_SIZE' value='$proxysettings{'MIN_SIZE'}' size='5' /></td>
e3edceeb 1098 <td class='base'>$Lang::tr{'advproxy max size'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
ac1cfefa
MT
1099 <td><input type='text' name='MAX_SIZE' value='$proxysettings{'MAX_SIZE'}' size='5' /></td>
1100</tr>
1101<tr>
ed38f89d 1102 <td class='base'>$Lang::tr{'advproxy number of L1 dirs'}:</td>
363fb6af
MT
1103 <td class='base'><select name='L1_DIRS'>
1104 <option value='16' $selected{'L1_DIRS'}{'16'}>16</option>
1105 <option value='32' $selected{'L1_DIRS'}{'32'}>32</option>
1106 <option value='64' $selected{'L1_DIRS'}{'64'}>64</option>
1107 <option value='128' $selected{'L1_DIRS'}{'128'}>128</option>
1108 <option value='256' $selected{'L1_DIRS'}{'256'}>256</option>
1109 </select></td>
ed38f89d 1110 <td colspan='2' rowspan= '5' valign='top' class='base'>
363fb6af 1111 <table cellspacing='0' cellpadding='0'>
ed38f89d
MT
1112 <tr>
1113 <!-- intentionally left empty -->
1114 </tr>
1115 <tr>
e3edceeb 1116 <td>$Lang::tr{'advproxy no cache sites'}:</td>
ed38f89d
MT
1117 </tr>
1118 <tr>
1119 <!-- intentionally left empty -->
1120 </tr>
1121 <tr>
1122 <!-- intentionally left empty -->
1123 </tr>
1124 <tr>
488d1b7c 1125 <td><textarea name='DST_NOCACHE' cols='32' rows='6' wrap='off'>
ed38f89d
MT
1126END
1127;
1128
1129print $proxysettings{'DST_NOCACHE'};
1130
1131print <<END
1132</textarea></td>
1133 </tr>
1134 </table>
1135 </td>
1136</tr>
1137<tr>
363fb6af
MT
1138 <td class='base'>$Lang::tr{'advproxy memory replacement policy'}:</td>
1139 <td class='base'><select name='MEM_POLICY'>
1140 <option value='LRU' $selected{'MEM_POLICY'}{'LRU'}>LRU</option>
1141 <option value='heap LFUDA' $selected{'MEM_POLICY'}{'heap LFUDA'}>heap LFUDA</option>
1142 <option value='heap GDSF' $selected{'MEM_POLICY'}{'heap GDSF'}>heap GDSF</option>
1143 <option value='heap LRU' $selected{'MEM_POLICY'}{'heap LRU'}>heap LRU</option>
1144 </select></td>
ed38f89d
MT
1145</tr>
1146<tr>
363fb6af
MT
1147 <td class='base'>$Lang::tr{'advproxy cache replacement policy'}:</td>
1148 <td class='base'><select name='CACHE_POLICY'>
1149 <option value='LRU' $selected{'CACHE_POLICY'}{'LRU'}>LRU</option>
1150 <option value='heap LFUDA' $selected{'CACHE_POLICY'}{'heap LFUDA'}>heap LFUDA</option>
1151 <option value='heap GDSF' $selected{'CACHE_POLICY'}{'heap GDSF'}>heap GDSF</option>
1152 <option value='heap LRU' $selected{'CACHE_POLICY'}{'heap LRU'}>heap LRU</option>
1153 </select></td>
ed38f89d
MT
1154</tr>
1155<tr>
1156 <td colspan='2'>&nbsp;</td>
1157</tr>
1158<tr>
363fb6af 1159 <td class='base'>$Lang::tr{'advproxy offline mode'}:</td>
ed38f89d
MT
1160 <td><input type='checkbox' name='OFFLINE_MODE' $checked{'OFFLINE_MODE'}{'on'} /></td>
1161</tr>
6bea848d
JB
1162<tr>
1163 <td class='base'>$Lang::tr{'advproxy cache-digest'}:</td>
1164 <td><input type='checkbox' name='CACHE_DIGESTS' $checked{'CACHE_DIGESTS'}{'on'} /></td>
1165</tr>
ed38f89d
MT
1166</table>
1167<hr size='1'>
1168<table width='100%'>
363fb6af
MT
1169<tr>
1170 <td colspan='4'><b>$Lang::tr{'advproxy destination ports'}</b></td>
1171</tr>
1172<tr>
631b67b7 1173 <td width='25%' align='center'></td> <td width='20%' align='center'></td><td width='25%' align='center'></td><td width='30%' align='center'></td>
363fb6af
MT
1174</tr>
1175<tr>
e3edceeb
LS
1176 <td colspan='2' class='base'>$Lang::tr{'advproxy standard ports'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1177 <td colspan='2' class='base'>$Lang::tr{'advproxy ssl ports'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
363fb6af
MT
1178</tr>
1179<tr>
1180 <td colspan='2'><textarea name='PORTS_SAFE' cols='32' rows='6' wrap='off'>
1181END
1182;
1183 if (!$proxysettings{'PORTS_SAFE'}) { print $def_ports_safe; } else { print $proxysettings{'PORTS_SAFE'}; }
1184
1185print <<END
1186</textarea></td>
1187 <td colspan='2'><textarea name='PORTS_SSL' cols='32' rows='6' wrap='off'>
1188END
1189;
1190 if (!$proxysettings{'PORTS_SSL'}) { print $def_ports_ssl; } else { print $proxysettings{'PORTS_SSL'}; }
1191
1192print <<END
1193</textarea></td>
1194</tr>
1195</table>
1196<hr size='1'>
1197<table width='100%'>
ed38f89d
MT
1198<tr>
1199 <td colspan='4'><b>$Lang::tr{'advproxy network based access'}</b></td>
1200</tr>
1201<tr>
1202 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1203</tr>
1204<tr>
e3edceeb 1205 <td colspan='4' class='base'>$Lang::tr{'advproxy allowed subnets'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
ed38f89d
MT
1206</tr>
1207<tr>
9141bd34 1208 <td colspan='2' rowspan='4'><textarea name='SRC_SUBNETS' cols='32' rows='3' wrap='off'>
ed38f89d
MT
1209END
1210;
1211
363fb6af
MT
1212if (!$proxysettings{'SRC_SUBNETS'})
1213{
ee4b5bbb
MT
1214 if (&Header::green_used()) {
1215 print "$green_cidr\n";
1216 }
1217
1218 if (&Header::blue_used()) {
f09a0af5 1219 print "$blue_cidr\n";
ed38f89d 1220 }
363fb6af 1221} else { print $proxysettings{'SRC_SUBNETS'}; }
ed38f89d
MT
1222
1223print <<END
1224</textarea></td>
9fb25b1c
MT
1225END
1226;
1227
1228$line = $Lang::tr{'advproxy no internal proxy on green'};
1229$line =~ s/Green/<font color="$Header::colourgreen">Green<\/font>/i;
1230print "<td class='base'>$line:</td>\n";
1231print <<END
1232 <td><input type='checkbox' name='NO_PROXY_LOCAL' $checked{'NO_PROXY_LOCAL'}{'on'} /></td>
1233</tr>
1234END
1235;
1236if ($netsettings{'BLUE_DEV'}) {
1237 $line = $Lang::tr{'advproxy no internal proxy on blue'};
1238 $line =~ s/Blue/<font color="$Header::colourblue">Blue<\/font>/i;
1239 print "<tr>\n";
1240 print "<td class='base'>$line:</td>\n";
1241 print <<END
1242 <td><input type='checkbox' name='NO_PROXY_LOCAL_BLUE' $checked{'NO_PROXY_LOCAL_BLUE'}{'on'} /></td>
1243</tr>
1244END
1245;
1246}
1247print <<END
1248<tr>
1249 <td colspan='2'>&nbsp;</td>
1250</tr>
1251<tr>
ed38f89d
MT
1252 <td colspan='2'>&nbsp;</td>
1253</tr>
1254</table>
1255<table width='100%'>
1256<tr>
1257 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1258</tr>
1259<tr>
e3edceeb
LS
1260 <td colspan='2' class='base'>$Lang::tr{'advproxy unrestricted ip clients'}:</td>
1261 <td colspan='2' class='base'>$Lang::tr{'advproxy unrestricted mac clients'}:</td>
ed38f89d
MT
1262</tr>
1263<tr>
9141bd34 1264 <td colspan='2'><textarea name='SRC_UNRESTRICTED_IP' cols='32' rows='3' wrap='off'>
ed38f89d
MT
1265END
1266;
1267
1268 print $proxysettings{'SRC_UNRESTRICTED_IP'};
1269
1270print <<END
1271</textarea></td>
9141bd34 1272 <td colspan='2'><textarea name='SRC_UNRESTRICTED_MAC' cols='32' rows='3' wrap='off'>
ed38f89d
MT
1273END
1274;
1275
1276print $proxysettings{'SRC_UNRESTRICTED_MAC'};
1277
1278print <<END
1279</textarea></td>
1280</tr>
1281</table>
1282<table width='100%'>
1283<tr>
1284 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1285</tr>
1286<tr>
e3edceeb
LS
1287 <td colspan='2' class='base'>$Lang::tr{'advproxy banned ip clients'}:</td>
1288 <td colspan='2' class='base'>$Lang::tr{'advproxy banned mac clients'}:</td>
ed38f89d
MT
1289</tr>
1290<tr>
9141bd34 1291 <td colspan='2'><textarea name='SRC_BANNED_IP' cols='32' rows='3' wrap='off'>
ed38f89d
MT
1292END
1293;
1294
1295 print $proxysettings{'SRC_BANNED_IP'};
1296
1297print <<END
1298</textarea></td>
9141bd34 1299 <td colspan='2'><textarea name='SRC_BANNED_MAC' cols='32' rows='3' wrap='off'>
ed38f89d
MT
1300END
1301;
1302
1303print $proxysettings{'SRC_BANNED_MAC'};
1304
1305print <<END
1306</textarea></td>
1307</tr>
1308</table>
1309
1310<hr size='1'>
1311
1312END
1313;
1314# -------------------------------------------------------------------
1315# CRE GUI - optional
1316# -------------------------------------------------------------------
1317
1318if (-e $cre_enabled) { print <<END
1319<table width='100%'>
1320
1321<tr>
9141bd34 1322 <td colspan='4'><b>$Lang::tr{'advproxy classroom extensions'}</b> $Lang::tr{'advproxy enabled'}:<input type='checkbox' name='CLASSROOM_EXT' $checked{'CLASSROOM_EXT'}{'on'} /></td>
ed38f89d
MT
1323</tr>
1324<tr>
1325 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1326</tr>
1327<tr>
9141bd34
CS
1328
1329END
1330;
1331if ($proxysettings{'CLASSROOM_EXT'} eq 'on'){
1332print <<END
e3edceeb 1333 <td class='base'>$Lang::tr{'advproxy supervisor password'}:</td>
ed38f89d
MT
1334 <td><input type='password' name='SUPERVISOR_PASSWORD' value='$proxysettings{'SUPERVISOR_PASSWORD'}' size='12' /></td>
1335</tr>
1336<tr>
1337 <td colspan='2' class='base'>$Lang::tr{'advproxy cre group definitions'}:</td>
e3edceeb 1338 <td colspan='2' class='base'>$Lang::tr{'advproxy cre supervisors'}:</td>
9141bd34
CS
1339END
1340;
1341}
1342print "</tr>";
1343if ($proxysettings{'CLASSROOM_EXT'} eq 'on'){
1344print <<END
ed38f89d
MT
1345<tr>
1346 <td colspan='2'><textarea name='CRE_GROUPS' cols='32' rows='6' wrap='off'>
1347END
1348;
1349
1350 print $proxysettings{'CRE_GROUPS'};
1351
1352print <<END
1353</textarea></td>
1354 <td colspan='2'><textarea name='CRE_SVHOSTS' cols='32' rows='6' wrap='off'>
1355END
1356;
1357 print $proxysettings{'CRE_SVHOSTS'};
1358
1359print <<END
1360</textarea></td>
1361</tr>
ed38f89d
MT
1362END
1363;
9141bd34
CS
1364}
1365print "</table><hr size='1'>";
1366
ed38f89d
MT
1367} else {
1368 print <<END
1369 <input type='hidden' name='SUPERVISOR_PASSWORD' value='$proxysettings{'SUPERVISOR_PASSWORD'}' />
1370 <input type='hidden' name='CRE_GROUPS' value='$proxysettings{'CRE_GROUPS'}' />
1371 <input type='hidden' name='CRE_SVHOSTS' value='$proxysettings{'CRE_SVHOSTS'}' />
1372END
1373;
1374}
363fb6af 1375
ce1c170b
AK
1376# ===================================================================
1377# WPAD settings
1378# ===================================================================
1379
1380print <<END
1381<table width='100%'>
1382<tr>
1383 <td colspan='4'><b>$Lang::tr{'advproxy wpad title'}</b></td>
1384</tr>
1385<tr>
1386 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1387</tr>
1388<tr>
1389 <td colspan='2' class='base'>$Lang::tr{'advproxy wpad label dst_noproxy_ip'}:</td>
1390 <td colspan='2' class='base'>$Lang::tr{'advproxy wpad label dst_noproxy_url'}:</td>
1391</tr>
1392<tr>
1393 <td colspan='2'><textarea name='DST_NOPROXY_IP' cols='32' rows='3' wrap='off'>
1394END
1395;
1396
1397 print $proxysettings{'DST_NOPROXY_IP'};
1398
1399print <<END
1400</textarea></td>
1401
1402 <td colspan='2'><textarea name='DST_NOPROXY_URL' cols='32' rows='3' wrap='off'>
1403END
1404;
1405
1406 print $proxysettings{'DST_NOPROXY_URL'};
1407
1408print <<END
1409</textarea></td>
1410</tr>
1411<tr>
1412 <td colspan='2' class='base'>$Lang::tr{'advproxy wpad example dst_noproxy_ip'}</td>
1413 <td colspan='2' class='base'>$Lang::tr{'advproxy wpad example dst_noproxy_url'}</td>
1414</tr>
1415<tr>
1416 <td colspan="4">&nbsp;</td>
1417</tr>
1418<tr>
1419 <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>
1420</tr>
cdc82a99
AK
1421<tr>
1422 <td colspan="4">&nbsp;</td>
1423</tr>
1424<tr>
1425 <td colspan="4">$Lang::tr{'advproxy wpad notice'}</td>
1426</tr>
ce1c170b
AK
1427</table>
1428
1429<hr size='1'>
1430
1431END
1432;
1433
ed38f89d
MT
1434# -------------------------------------------------------------------
1435
28c9dec6 1436print <<END
ed38f89d
MT
1437
1438<table width='100%'>
1439<tr>
363fb6af 1440 <td colspan='4'><b>$Lang::tr{'advproxy time restrictions'}</b></td>
ed38f89d
MT
1441</tr>
1442<table width='100%'>
1443<tr>
1444 <td width='2%'>$Lang::tr{'advproxy access'}</td>
1445 <td width='1%'>&nbsp;</td>
1446 <td width='2%' align='center'>$Lang::tr{'advproxy monday'}</td>
1447 <td width='2%' align='center'>$Lang::tr{'advproxy tuesday'}</td>
1448 <td width='2%' align='center'>$Lang::tr{'advproxy wednesday'}</td>
1449 <td width='2%' align='center'>$Lang::tr{'advproxy thursday'}</td>
1450 <td width='2%' align='center'>$Lang::tr{'advproxy friday'}</td>
1451 <td width='2%' align='center'>$Lang::tr{'advproxy saturday'}</td>
1452 <td width='2%' align='center'>$Lang::tr{'advproxy sunday'}</td>
1453 <td width='1%'>&nbsp;&nbsp;</td>
1454 <td width='7%' colspan=3>$Lang::tr{'advproxy from'}</td>
1455 <td width='1%'>&nbsp;</td>
1456 <td width='7%' colspan=3>$Lang::tr{'advproxy to'}</td>
1457 <td>&nbsp;</td>
1458</tr>
1459<tr>
1460 <td class='base'>
1461 <select name='TIME_ACCESS_MODE'>
1462 <option value='allow' $selected{'TIME_ACCESS_MODE'}{'allow'}>$Lang::tr{'advproxy mode allow'}</option>
1463 <option value='deny' $selected{'TIME_ACCESS_MODE'}{'deny'}>$Lang::tr{'advproxy mode deny'}</option>
1464 </select>
1465 </td>
1466 <td>&nbsp;</td>
1467 <td class='base'><input type='checkbox' name='TIME_MON' $checked{'TIME_MON'}{'on'} /></td>
1468 <td class='base'><input type='checkbox' name='TIME_TUE' $checked{'TIME_TUE'}{'on'} /></td>
1469 <td class='base'><input type='checkbox' name='TIME_WED' $checked{'TIME_WED'}{'on'} /></td>
1470 <td class='base'><input type='checkbox' name='TIME_THU' $checked{'TIME_THU'}{'on'} /></td>
1471 <td class='base'><input type='checkbox' name='TIME_FRI' $checked{'TIME_FRI'}{'on'} /></td>
1472 <td class='base'><input type='checkbox' name='TIME_SAT' $checked{'TIME_SAT'}{'on'} /></td>
1473 <td class='base'><input type='checkbox' name='TIME_SUN' $checked{'TIME_SUN'}{'on'} /></td>
1474 <td>&nbsp;</td>
1475 <td class='base'>
1476 <select name='TIME_FROM_HOUR'>
1477END
1478;
1479for ($i=0;$i<=24;$i++) {
1480 $_ = sprintf("%02s",$i);
1481 print "<option $selected{'TIME_FROM_HOUR'}{$_}>$_</option>\n";
1482}
1483print <<END
1484 </select>
1485 </td>
1486 <td>:</td>
1487 <td class='base'>
1488 <select name='TIME_FROM_MINUTE'>
1489END
1490;
1491for ($i=0;$i<=45;$i+=15) {
1492 $_ = sprintf("%02s",$i);
1493 print "<option $selected{'TIME_FROM_MINUTE'}{$_}>$_</option>\n";
1494}
1495print <<END
1496 </select>
1497 <td> - </td>
1498 </td>
1499 <td class='base'>
1500 <select name='TIME_TO_HOUR'>
1501END
1502;
1503for ($i=0;$i<=24;$i++) {
1504 $_ = sprintf("%02s",$i);
1505 print "<option $selected{'TIME_TO_HOUR'}{$_}>$_</option>\n";
1506}
1507print <<END
1508 </select>
1509 </td>
1510 <td>:</td>
1511 <td class='base'>
1512 <select name='TIME_TO_MINUTE'>
1513END
1514;
1515for ($i=0;$i<=45;$i+=15) {
1516 $_ = sprintf("%02s",$i);
1517 print "<option $selected{'TIME_TO_MINUTE'}{$_}>$_</option>\n";
1518}
1519print <<END
1520 </select>
1521 </td>
1522</tr>
1523</table>
1524<hr size='1'>
1525<table width='100%'>
1526<tr>
1527 <td colspan='4'><b>$Lang::tr{'advproxy transfer limits'}</b></td>
ac1cfefa
MT
1528</tr>
1529<tr>
e3edceeb 1530 <td width='25%' class='base'>$Lang::tr{'advproxy max download size'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
ed38f89d 1531 <td width='20%'><input type='text' name='MAX_INCOMING_SIZE' value='$proxysettings{'MAX_INCOMING_SIZE'}' size='5' /></td>
e3edceeb 1532 <td width='25%' class='base'>$Lang::tr{'advproxy max upload size'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
ed38f89d 1533 <td width='30%'><input type='text' name='MAX_OUTGOING_SIZE' value='$proxysettings{'MAX_OUTGOING_SIZE'}' size='5' /></td>
ac1cfefa
MT
1534</tr>
1535</table>
ed38f89d 1536<hr size='1'>
ac1cfefa 1537<table width='100%'>
ac1cfefa 1538<tr>
ed38f89d
MT
1539 <td colspan='4'><b>$Lang::tr{'advproxy download throttling'}</b></td>
1540</tr>
1541<tr>
1542 <td width='25%' class='base'>$Lang::tr{'advproxy throttling total on'} <font color="$Header::colourgreen">Green</font>:</td>
1543 <td width='20%' class='base'>
1544 <select name='THROTTLING_GREEN_TOTAL'>
1545END
1546;
1547
1548foreach (@throttle_limits) {
ce1f04ee
MT
1549 my $val = $_;
1550 my $unit = "kbit/s";
1551
1552 if ($val >= 1024) {
1553 $unit = "Mbit/s";
1554 $val /= 1024;
1555 }
1556
1557 print "\t<option value='$_' $selected{'THROTTLING_GREEN_TOTAL'}{$_}>$val $unit</option>\n";
ed38f89d
MT
1558}
1559
1560print <<END
1561 <option value='0' $selected{'THROTTLING_GREEN_TOTAL'}{'unlimited'}>$Lang::tr{'advproxy throttling unlimited'}</option>\n";
1562 </select>
1563 </td>
1564 <td width='25%' class='base'>$Lang::tr{'advproxy throttling per host on'} <font color="$Header::colourgreen">Green</font>:</td>
1565 <td width='30%' class='base'>
1566 <select name='THROTTLING_GREEN_HOST'>
1567END
1568;
1569
1570foreach (@throttle_limits) {
f00699e8 1571 print "\t<option value='$_' $selected{'THROTTLING_GREEN_HOST'}{$_}>$_ kbit/s</option>\n";
ed38f89d
MT
1572}
1573
1574print <<END
1575 <option value='0' $selected{'THROTTLING_GREEN_HOST'}{'unlimited'}>$Lang::tr{'advproxy throttling unlimited'}</option>\n";
1576 </select>
1577 </td>
1578</tr>
1579END
1580;
1581
1582if ($netsettings{'BLUE_DEV'}) {
1583 print <<END
1584<tr>
1585 <td class='base'>$Lang::tr{'advproxy throttling total on'} <font color="$Header::colourblue">Blue</font>:</td>
1586 <td class='base'>
1587 <select name='THROTTLING_BLUE_TOTAL'>
1588END
1589;
1590
1591foreach (@throttle_limits) {
f00699e8 1592 print "\t<option value='$_' $selected{'THROTTLING_BLUE_TOTAL'}{$_}>$_ kbit/s</option>\n";
ed38f89d
MT
1593}
1594
1595print <<END
1596 <option value='0' $selected{'THROTTLING_BLUE_TOTAL'}{'unlimited'}>$Lang::tr{'advproxy throttling unlimited'}</option>\n";
1597 </select>
1598 </td>
1599 <td class='base'>$Lang::tr{'advproxy throttling per host on'} <font color="$Header::colourblue">Blue</font>:</td>
1600 <td class='base'>
1601 <select name='THROTTLING_BLUE_HOST'>
1602END
1603;
1604
1605foreach (@throttle_limits) {
f00699e8 1606 print "\t<option value='$_' $selected{'THROTTLING_BLUE_HOST'}{$_}>$_ kbit/s</option>\n";
ed38f89d
MT
1607}
1608
1609print <<END
1610 <option value='0' $selected{'THROTTLING_BLUE_HOST'}{'unlimited'}>$Lang::tr{'advproxy throttling unlimited'}</option>\n";
1611 </select>
ac1cfefa 1612 </td>
ac1cfefa 1613</tr>
ed38f89d
MT
1614END
1615;
1616}
ac1cfefa 1617
ed38f89d
MT
1618print <<END
1619</table>
ed38f89d
MT
1620<hr size='1'>
1621<table width='100%'>
1622<tr>
9141bd34 1623 <td colspan='4'><b>$Lang::tr{'advproxy MIME filter'}</b> $Lang::tr{'advproxy enabled'}:<input type='checkbox' name='ENABLE_MIME_FILTER' $checked{'ENABLE_MIME_FILTER'}{'on'} /></td>
ed38f89d 1624</tr>
9141bd34
CS
1625END
1626;
1627if ( $proxysettings{'ENABLE_MIME_FILTER'} eq 'on' ){
1628print <<END
ed38f89d 1629<tr>
e3edceeb 1630 <td colspan='2' class='base'>$Lang::tr{'advproxy MIME block types'}:</td>
363fb6af
MT
1631 <td>&nbsp;</td>
1632 <td>&nbsp;</td>
ed38f89d
MT
1633</tr>
1634<tr>
1635 <td colspan='2'><textarea name='MIME_TYPES' cols='32' rows='6' wrap='off'>
ac1cfefa
MT
1636END
1637;
ac1cfefa 1638
ed38f89d 1639print $proxysettings{'MIME_TYPES'};
ac1cfefa 1640
ed38f89d
MT
1641print <<END
1642</textarea></td>
363fb6af
MT
1643 <td>&nbsp;</td>
1644 <td>&nbsp;</td>
ed38f89d 1645</tr>
9141bd34
CS
1646END
1647;
1648}
1649print <<END
ed38f89d 1650</table>
9141bd34 1651
bb5ca283
PM
1652<hr size='1'>
1653
1654<table width='100%'>
1655<tr>
1656 <td><b>$Lang::tr{'advproxy asbased anomaly detection'}</b></td>
1657</tr>
1658<tr>
1659 <td class='base'>$Lang::tr{'advproxy fastflux detection'}:</td>
1660 <td><input type='checkbox' name='ASNBL_FASTFLUX_DETECTION' $checked{'ASNBL_FASTFLUX_DETECTION'}{'on'} /></td>
1661 <td class='base'>$Lang::tr{'advproxy fastflux detection threshold'}:</td>
1662 <td><input type='text' name='ASNBL_FASTFLUX_THRESHOLD' value='$proxysettings{'ASNBL_FASTFLUX_THRESHOLD'}' size=2 /></td>
1663</tr>
1664<tr>
1665 <td class='base'>$Lang::tr{'advproxy selectively announcements detection'}:</td>
1666 <td colspan='3'><input type='checkbox' name='ASNBL_SELECANN_DETECTION' $checked{'ASNBL_SELECANN_DETECTION'}{'on'} /></td>
1667</tr>
1668</table>
1669
ed38f89d
MT
1670<hr size='1'>
1671END
1672;
1673
603248db
MT
1674my $auth_columns = 5;
1675if ($HAVE_NTLM_AUTH) {
1676 $auth_columns++;
1677}
1678my $auth_column_width = 100 / $auth_columns;
1679
1680print <<END;
ed38f89d
MT
1681<table width='100%'>
1682<tr>
603248db 1683 <td colspan='$auth_columns'><b>$Lang::tr{'advproxy AUTH method'}</b></td>
ed38f89d
MT
1684</tr>
1685<tr>
603248db
MT
1686 <td width='$auth_column_width%' class='base'><input type='radio' name='AUTH_METHOD' value='none' $checked{'AUTH_METHOD'}{'none'} />$Lang::tr{'advproxy AUTH method none'}</td>
1687 <td width='$auth_column_width%' class='base'><input type='radio' name='AUTH_METHOD' value='ncsa' $checked{'AUTH_METHOD'}{'ncsa'} />$Lang::tr{'advproxy AUTH method ncsa'}</td>
1688 <td width='$auth_column_width%' class='base'><input type='radio' name='AUTH_METHOD' value='ident' $checked{'AUTH_METHOD'}{'ident'} />$Lang::tr{'advproxy AUTH method ident'}</td>
1689 <td width='$auth_column_width%' class='base'><input type='radio' name='AUTH_METHOD' value='ldap' $checked{'AUTH_METHOD'}{'ldap'} />$Lang::tr{'advproxy AUTH method ldap'}</td>
603248db
MT
1690END
1691
1692if ($HAVE_NTLM_AUTH) {
1693 print <<END;
1694 <td width='$auth_column_width%' class='base'><input type='radio' name='AUTH_METHOD' value='ntlm-auth' $checked{'AUTH_METHOD'}{'ntlm-auth'} />$Lang::tr{'advproxy AUTH method ntlm auth'}</td>
1695END
1696}
1697
1698print <<END
1699 <td width='$auth_column_width%' class='base'><input type='radio' name='AUTH_METHOD' value='radius' $checked{'AUTH_METHOD'}{'radius'} />$Lang::tr{'advproxy AUTH method radius'}</td>
ed38f89d
MT
1700</tr>
1701</table>
1702END
1703;
1704
1705if (!($proxysettings{'AUTH_METHOD'} eq 'none')) { if (!($proxysettings{'AUTH_METHOD'} eq 'ident')) { print <<END
1706<hr size='1'>
1707<table width='100%'>
1708<tr>
363fb6af 1709 <td colspan='4'><b>$Lang::tr{'advproxy AUTH global settings'}</b></td>
ed38f89d
MT
1710</tr>
1711<tr>
1712 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1713</tr>
1714<tr>
1715 <td class='base'>$Lang::tr{'advproxy AUTH number of auth processes'}:</td>
1716 <td><input type='text' name='AUTH_CHILDREN' value='$proxysettings{'AUTH_CHILDREN'}' size='5' /></td>
1717 <td colspan='2' rowspan= '6' valign='top' class='base'>
1718 <table cellpadding='0' cellspacing='0'>
1719 <tr>
e3edceeb 1720 <td class='base'>$Lang::tr{'advproxy AUTH realm'}:</td>
ed38f89d
MT
1721 </tr>
1722 <tr>
1723 <!-- intentionally left empty -->
1724 </tr>
1725 <tr>
1726 <!-- intentionally left empty -->
1727 </tr>
1728 <tr>
1729 <td><input type='text' name='AUTH_REALM' value='$proxysettings{'AUTH_REALM'}' size='40' /></td>
1730 </tr>
1731 <tr>
1732 <!-- intentionally left empty -->
1733 </tr>
1734 <tr>
1735 <!-- intentionally left empty -->
1736 </tr>
1737 <tr>
e3edceeb 1738 <td>$Lang::tr{'advproxy AUTH no auth'}:</td>
ed38f89d
MT
1739 </tr>
1740 <tr>
1741 <!-- intentionally left empty -->
1742 </tr>
1743 <tr>
1744 <!-- intentionally left empty -->
1745 </tr>
1746 <tr>
1747 <td><textarea name='DST_NOAUTH' cols='32' rows='6' wrap='off'>
1748END
1749;
1750
1751print $proxysettings{'DST_NOAUTH'};
1752
1753print <<END
1754</textarea></td>
1755 </tr>
1756 </table>
1757 </td>
1758</tr>
1759<tr>
1760 <td class='base'>$Lang::tr{'advproxy AUTH auth cache TTL'}:</td>
1761 <td><input type='text' name='AUTH_CACHE_TTL' value='$proxysettings{'AUTH_CACHE_TTL'}' size='5' /></td>
1762</tr>
1763<tr>
e3edceeb 1764 <td class='base'>$Lang::tr{'advproxy AUTH limit of IP addresses'}:</td>
ed38f89d
MT
1765 <td><input type='text' name='AUTH_MAX_USERIP' value='$proxysettings{'AUTH_MAX_USERIP'}' size='5' /></td>
1766</tr>
0f8251fe
PM
1767<tr>
1768 <td class='base'>$Lang::tr{'advproxy AUTH user IP cache TTL'}:</td>
1769 <td><input type='text' name='AUTH_IPCACHE_TTL' value='$proxysettings{'AUTH_IPCACHE_TTL'}' size='5' /></td>
1770</tr>
ed38f89d 1771<tr>
363fb6af
MT
1772 <td class='base'>$Lang::tr{'advproxy AUTH always required'}:</td>
1773 <td><input type='checkbox' name='AUTH_ALWAYS_REQUIRED' $checked{'AUTH_ALWAYS_REQUIRED'}{'on'} /></td>
ed38f89d
MT
1774</tr>
1775<tr>
1776 <td colspan='2'>&nbsp;</td>
1777</tr>
1778</table>
1779END
1780;
1781}
1782
1783# ===================================================================
1784# NCSA auth settings
1785# ===================================================================
1786
1787if ($proxysettings{'AUTH_METHOD'} eq 'ncsa') {
1788print <<END
1789<hr size='1'>
1790<table width='100%'>
1791<tr>
1792 <td colspan='4'><b>$Lang::tr{'advproxy NCSA auth'}</b></td>
1793</tr>
1794<tr>
1795 <td width='25%' class='base'>$Lang::tr{'advproxy NCSA min password length'}:</td>
1796 <td width='20%'><input type='text' name='NCSA_MIN_PASS_LEN' value='$proxysettings{'NCSA_MIN_PASS_LEN'}' size='5' /></td>
1797 <td width='25%' class='base'>$Lang::tr{'advproxy NCSA redirector bypass'} \'$Lang::tr{'advproxy NCSA grp extended'}\':</td>
363fb6af 1798 <td width='20%'><input type='checkbox' name='NCSA_BYPASS_REDIR' $checked{'NCSA_BYPASS_REDIR'}{'on'} /></td>
ed38f89d
MT
1799</tr>
1800<tr>
1801 <td colspan='2'><br>&nbsp;<input type='submit' name='ACTION' value='$Lang::tr{'advproxy NCSA user management'}'></td>
1802 <td>&nbsp;</td>
1803 <td>&nbsp;</td>
1804</tr>
1805</table>
1806END
1807; }
1808
1809# ===================================================================
1810# IDENTD auth settings
1811# ===================================================================
1812
1813if ($proxysettings{'AUTH_METHOD'} eq 'ident') {
1814print <<END
1815<hr size ='1'>
1816<table width='100%'>
1817<tr>
1818 <td colspan='4'><b>$Lang::tr{'advproxy IDENT identd settings'}</b></td>
1819</tr>
1820<tr>
1821 <td width='25%' class='base'>$Lang::tr{'advproxy IDENT required'}:</td>
363fb6af
MT
1822 <td width='20%'><input type='checkbox' name='IDENT_REQUIRED' $checked{'IDENT_REQUIRED'}{'on'} /></td>
1823 <td width='25%' class='base'>$Lang::tr{'advproxy AUTH always required'}:</td>
1824 <td width='30%'><input type='checkbox' name='AUTH_ALWAYS_REQUIRED' $checked{'AUTH_ALWAYS_REQUIRED'}{'on'} /></td>
ed38f89d
MT
1825</tr>
1826<tr>
1827 <td class='base'>$Lang::tr{'advproxy IDENT timeout'}:</td>
1828 <td><input type='text' name='IDENT_TIMEOUT' value='$proxysettings{'IDENT_TIMEOUT'}' size='5' /></td>
1829 <td>&nbsp;</td>
1830 <td>&nbsp;</td>
1831</tr>
1832<tr>
1833 <td colspan='2' class='base'>$Lang::tr{'advproxy IDENT aware hosts'}:</td>
e3edceeb 1834 <td colspan='2' class='base'>$Lang::tr{'advproxy AUTH no auth'}:</td>
ed38f89d
MT
1835</tr>
1836<tr>
1837 <td colspan='2'><textarea name='IDENT_HOSTS' cols='32' rows='6' wrap='off'>
1838END
1839;
1840if (!$proxysettings{'IDENT_HOSTS'}) {
ee4b5bbb
MT
1841 if (&Header::green_used()) {
1842 print "$green_cidr\n";
1843 }
1844
1845 if (&Header::blue_used()) {
f09a0af5 1846 print "$blue_cidr\n";
ed38f89d
MT
1847 }
1848} else {
1849 print $proxysettings{'IDENT_HOSTS'};
1850}
1851
1852print <<END
1853</textarea></td>
1854 <td colspan='2'><textarea name='DST_NOAUTH' cols='32' rows='6' wrap='off'>
1855END
1856;
1857
1858print $proxysettings{'DST_NOAUTH'};
1859
1860print <<END
1861</textarea></td>
1862</tr>
1863</table>
1864<hr size ='1'>
1865<table width='100%'>
1866<tr>
1867 <td colspan='4'><b>$Lang::tr{'advproxy IDENT user based access restrictions'}</b></td>
1868</tr>
1869<tr>
1870 <td width='25%' class='base'>$Lang::tr{'advproxy enabled'}:</td>
1871 <td width='20%'><input type='checkbox' name='IDENT_ENABLE_ACL' $checked{'IDENT_ENABLE_ACL'}{'on'} /></td>
1872 <td width='25%'>&nbsp;</td>
1873 <td width='30%'>&nbsp;</td>
1874</tr>
1875<tr>
1876 <td colspan='2'><input type='radio' name='IDENT_USER_ACL' value='positive' $checked{'IDENT_USER_ACL'}{'positive'} />
1877 $Lang::tr{'advproxy IDENT use positive access list'}:</td>
1878 <td colspan='2'><input type='radio' name='IDENT_USER_ACL' value='negative' $checked{'IDENT_USER_ACL'}{'negative'} />
1879 $Lang::tr{'advproxy IDENT use negative access list'}:</td>
1880</tr>
1881<tr>
1882 <td colspan='2'>$Lang::tr{'advproxy IDENT authorized users'}</td>
1883 <td colspan='2'>$Lang::tr{'advproxy IDENT unauthorized users'}</td>
1884</tr>
1885<tr>
363fb6af 1886 <td colspan='2'><textarea name='IDENT_ALLOW_USERS' cols='32' rows='6' wrap='off'>
ed38f89d
MT
1887END
1888; }
1889
1890if ($proxysettings{'AUTH_METHOD'} eq 'ident') { print $proxysettings{'IDENT_ALLOW_USERS'}; }
1891
1892if ($proxysettings{'AUTH_METHOD'} eq 'ident') { print <<END
1893</textarea></td>
363fb6af 1894 <td colspan='2'><textarea name='IDENT_DENY_USERS' cols='32' rows='6' wrap='off'>
ed38f89d
MT
1895END
1896; }
1897
1898if ($proxysettings{'AUTH_METHOD'} eq 'ident') { print $proxysettings{'IDENT_DENY_USERS'}; }
1899
1900if ($proxysettings{'AUTH_METHOD'} eq 'ident') { print <<END
1901</textarea></td>
1902</tr>
1903</table>
1904END
1905; }
1906
b5674643
MT
1907# ===================================================================
1908# NTLM-AUTH settings
1909# ===================================================================
1910
1911if ($proxysettings{'AUTH_METHOD'} eq 'ntlm-auth') {
1912 print <<END;
1913 <hr size ='1'>
2fc5124b
MT
1914 <table width='100%'>
1915 <td width='20%' class='base'>$Lang::tr{'advproxy basic authentication'}:</td>
1916 <td width='40%'><input type='checkbox' name='NTLM_AUTH_BASIC' $checked{'NTLM_AUTH_BASIC'}{'on'} /></td>
1917 <td colspan='2'>&nbsp;</td>
1918 </table>
1919
1920 <hr size='1' />
1921
b5674643
MT
1922 <table width='100%'>
1923 <tr>
1924 <td colspan='4'><b>$Lang::tr{'advproxy group access control'}</b></td>
1925 </tr>
1926 <tr>
e3edceeb 1927 <td width='20%' class='base'>$Lang::tr{'advproxy group required'}:</td>
b5674643
MT
1928 <td width='40%'><input type='text' name='NTLM_AUTH_GROUP' value='$proxysettings{'NTLM_AUTH_GROUP'}' size='37' /></td>
1929 <td>&nbsp;</td>
1930 <td>&nbsp;</td>
1931 </tr>
1932 </table>
1933END
1934}
1935
ed38f89d
MT
1936# ===================================================================
1937# LDAP auth settings
1938# ===================================================================
1939
1940if ($proxysettings{'AUTH_METHOD'} eq 'ldap') {
1941print <<END
1942<hr size='1'>
1943<table width='100%'>
1944<tr>
1945 <td colspan='4'><b>$Lang::tr{'advproxy LDAP common settings'}</b></td>
1946</tr>
1947<tr>
1948 <td class='base'>$Lang::tr{'advproxy LDAP basedn'}:</td>
1949 <td><input type='text' name='LDAP_BASEDN' value='$proxysettings{'LDAP_BASEDN'}' size='37' /></td>
1950 <td class='base'>$Lang::tr{'advproxy LDAP type'}:</td>
1951 <td class='base'><select name='LDAP_TYPE'>
1952 <option value='ADS' $selected{'LDAP_TYPE'}{'ADS'}>$Lang::tr{'advproxy LDAP ADS'}</option>
1953 <option value='NDS' $selected{'LDAP_TYPE'}{'NDS'}>$Lang::tr{'advproxy LDAP NDS'}</option>
1954 <option value='V2' $selected{'LDAP_TYPE'}{'V2'}>$Lang::tr{'advproxy LDAP V2'}</option>
1955 <option value='V3' $selected{'LDAP_TYPE'}{'V3'}>$Lang::tr{'advproxy LDAP V3'}</option>
1956 </select></td>
1957</tr>
1958<tr>
1959 <td width='20%' class='base'>$Lang::tr{'advproxy LDAP server'}:</td>
1960 <td width='40%'><input type='text' name='LDAP_SERVER' value='$proxysettings{'LDAP_SERVER'}' size='14' /></td>
1961 <td width='20%' class='base'>$Lang::tr{'advproxy LDAP port'}:</td>
1962 <td><input type='text' name='LDAP_PORT' value='$proxysettings{'LDAP_PORT'}' size='3' /></td>
1963</tr>
1964</table>
1965<hr size ='1'>
1966<table width='100%'>
1967<tr>
1968 <td colspan='4'><b>$Lang::tr{'advproxy LDAP binddn settings'}</b></td>
1969</tr>
1970<tr>
1971 <td width='20%' class='base'>$Lang::tr{'advproxy LDAP binddn username'}:</td>
1972 <td width='40%'><input type='text' name='LDAP_BINDDN_USER' value='$proxysettings{'LDAP_BINDDN_USER'}' size='37' /></td>
1973 <td width='20%' class='base'>$Lang::tr{'advproxy LDAP binddn password'}:</td>
1974 <td><input type='password' name='LDAP_BINDDN_PASS' value='$proxysettings{'LDAP_BINDDN_PASS'}' size='14' /></td>
1975</tr>
1976</table>
1977<hr size ='1'>
1978<table width='100%'>
1979<tr>
1980 <td colspan='4'><b>$Lang::tr{'advproxy LDAP group access control'}</b></td>
1981</tr>
1982<tr>
e3edceeb 1983 <td width='20%' class='base'>$Lang::tr{'advproxy LDAP group required'}:</td>
ed38f89d
MT
1984 <td width='40%'><input type='text' name='LDAP_GROUP' value='$proxysettings{'LDAP_GROUP'}' size='37' /></td>
1985 <td>&nbsp;</td>
1986 <td>&nbsp;</td>
1987</tr>
1988</table>
1989END
1990; }
1991
1992# ===================================================================
1993# RADIUS auth settings
1994# ===================================================================
1995
1996if ($proxysettings{'AUTH_METHOD'} eq 'radius') {
1997print <<END
1998<hr size='1'>
1999<table width='100%'>
2000<tr>
2001 <td colspan='4'><b>$Lang::tr{'advproxy RADIUS radius settings'}</b></td>
2002</tr>
2003<tr>
2004 <td width='25%' class='base'>$Lang::tr{'advproxy RADIUS server'}:</td>
2005 <td width='20%'><input type='text' name='RADIUS_SERVER' value='$proxysettings{'RADIUS_SERVER'}' size='14' /></td>
2006 <td width='25%' class='base'>$Lang::tr{'advproxy RADIUS port'}:</td>
2007 <td width='30%'><input type='text' name='RADIUS_PORT' value='$proxysettings{'RADIUS_PORT'}' size='3' /></td>
2008</tr>
2009<tr>
e3edceeb 2010 <td class='base'>$Lang::tr{'advproxy RADIUS identifier'}:</td>
ed38f89d
MT
2011 <td><input type='text' name='RADIUS_IDENTIFIER' value='$proxysettings{'RADIUS_IDENTIFIER'}' size='14' /></td>
2012 <td class='base'>$Lang::tr{'advproxy RADIUS secret'}:</td>
2013 <td><input type='password' name='RADIUS_SECRET' value='$proxysettings{'RADIUS_SECRET'}' size='14' /></td>
2014</tr>
2015</table>
2016<hr size ='1'>
2017<table width='100%'>
2018<tr>
2019 <td colspan='4'><b>$Lang::tr{'advproxy RADIUS user based access restrictions'}</b></td>
2020</tr>
2021<tr>
2022 <td width='25%' class='base'>$Lang::tr{'advproxy enabled'}:</td>
2023 <td width='20%'><input type='checkbox' name='RADIUS_ENABLE_ACL' $checked{'RADIUS_ENABLE_ACL'}{'on'} /></td>
2024 <td width='25%'>&nbsp;</td>
2025 <td width='30%'>&nbsp;</td>
2026</tr>
2027<tr>
2028 <td colspan='2'><input type='radio' name='RADIUS_USER_ACL' value='positive' $checked{'RADIUS_USER_ACL'}{'positive'} />
2029 $Lang::tr{'advproxy RADIUS use positive access list'}:</td>
2030 <td colspan='2'><input type='radio' name='RADIUS_USER_ACL' value='negative' $checked{'RADIUS_USER_ACL'}{'negative'} />
2031 $Lang::tr{'advproxy RADIUS use negative access list'}:</td>
2032</tr>
2033<tr>
2034 <td colspan='2'>$Lang::tr{'advproxy RADIUS authorized users'}</td>
2035 <td colspan='2'>$Lang::tr{'advproxy RADIUS unauthorized users'}</td>
2036</tr>
2037<tr>
363fb6af 2038 <td colspan='2'><textarea name='RADIUS_ALLOW_USERS' cols='32' rows='6' wrap='off'>
ed38f89d
MT
2039END
2040; }
2041
2042if ($proxysettings{'AUTH_METHOD'} eq 'radius') { print $proxysettings{'RADIUS_ALLOW_USERS'}; }
2043
2044if ($proxysettings{'AUTH_METHOD'} eq 'radius') { print <<END
2045</textarea></td>
363fb6af 2046 <td colspan='2'><textarea name='RADIUS_DENY_USERS' cols='32' rows='6' wrap='off'>
ed38f89d
MT
2047END
2048; }
2049
2050if ($proxysettings{'AUTH_METHOD'} eq 'radius') { print $proxysettings{'RADIUS_DENY_USERS'}; }
2051
2052if ($proxysettings{'AUTH_METHOD'} eq 'radius') { print <<END
2053</textarea></td>
2054</tr>
2055</table>
2056END
2057; }
2058
2059# ===================================================================
2060
2061}
2062
2063print "<table>\n";
2064
2065if ($proxysettings{'AUTH_METHOD'} eq 'none') {
2066print <<END
2067<td><input type='hidden' name='AUTH_CHILDREN' value='$proxysettings{'AUTH_CHILDREN'}'></td>
2068<td><input type='hidden' name='AUTH_CACHE_TTL' value='$proxysettings{'AUTH_CACHE_TTL'}' size='5' /></td>
2069<td><input type='hidden' name='AUTH_MAX_USERIP' value='$proxysettings{'AUTH_MAX_USERIP'}' size='5' /></td>
0f8251fe 2070<td><input type='hidden' name='AUTH_IPCACHE_TTL' value='$proxysettings{'AUTH_IPCACHE_TTL'}' size='5' /></td>
ed38f89d
MT
2071<td><input type='hidden' name='AUTH_ALWAYS_REQUIRED' value='$proxysettings{'AUTH_ALWAYS_REQUIRED'}'></td>
2072<td><input type='hidden' name='AUTH_REALM' value='$proxysettings{'AUTH_REALM'}'></td>
2073<td><input type='hidden' name='DST_NOAUTH' value='$proxysettings{'DST_NOAUTH'}'></td>
2074END
2075; }
2076
2077if ($proxysettings{'AUTH_METHOD'} eq 'ident') {
2078print <<END
2079<td><input type='hidden' name='AUTH_CHILDREN' value='$proxysettings{'AUTH_CHILDREN'}'></td>
2080<td><input type='hidden' name='AUTH_CACHE_TTL' value='$proxysettings{'AUTH_CACHE_TTL'}' size='5' /></td>
2081<td><input type='hidden' name='AUTH_MAX_USERIP' value='$proxysettings{'AUTH_MAX_USERIP'}' size='5' /></td>
0f8251fe 2082<td><input type='hidden' name='AUTH_IPCACHE_TTL' value='$proxysettings{'AUTH_IPCACHE_TTL'}' size='5' /></td>
ed38f89d
MT
2083<td><input type='hidden' name='AUTH_REALM' value='$proxysettings{'AUTH_REALM'}'></td>
2084END
2085; }
2086
2087if (!($proxysettings{'AUTH_METHOD'} eq 'ncsa')) {
2088print <<END
2089<td><input type='hidden' name='NCSA_MIN_PASS_LEN' value='$proxysettings{'NCSA_MIN_PASS_LEN'}'></td>
2090<td><input type='hidden' name='NCSA_BYPASS_REDIR' value='$proxysettings{'NCSA_BYPASS_REDIR'}'></td>
2091END
2092; }
2093
2094if (!($proxysettings{'AUTH_METHOD'} eq 'ident')) {
2095print <<END
2096<td><input type='hidden' name='IDENT_REQUIRED' value='$proxysettings{'IDENT_REQUIRED'}'></td>
2097<td><input type='hidden' name='IDENT_TIMEOUT' value='$proxysettings{'IDENT_TIMEOUT'}'></td>
2098<td><input type='hidden' name='IDENT_HOSTS' value='$proxysettings{'IDENT_HOSTS'}'></td>
2099<td><input type='hidden' name='IDENT_ENABLE_ACL' value='$proxysettings{'IDENT_ENABLE_ACL'}'></td>
2100<td><input type='hidden' name='IDENT_USER_ACL' value='$proxysettings{'IDENT_USER_ACL'}'></td>
2101<td><input type='hidden' name='IDENT_ALLOW_USERS' value='$proxysettings{'IDENT_ALLOW_USERS'}'></td>
2102<td><input type='hidden' name='IDENT_DENY_USERS' value='$proxysettings{'IDENT_DENY_USERS'}'></td>
2103END
2104; }
2105
2106if (!($proxysettings{'AUTH_METHOD'} eq 'ldap')) {
2107print <<END
2108<td><input type='hidden' name='LDAP_BASEDN' value='$proxysettings{'LDAP_BASEDN'}'></td>
2109<td><input type='hidden' name='LDAP_TYPE' value='$proxysettings{'LDAP_TYPE'}'></td>
2110<td><input type='hidden' name='LDAP_SERVER' value='$proxysettings{'LDAP_SERVER'}'></td>
2111<td><input type='hidden' name='LDAP_PORT' value='$proxysettings{'LDAP_PORT'}'></td>
2112<td><input type='hidden' name='LDAP_BINDDN_USER' value='$proxysettings{'LDAP_BINDDN_USER'}'></td>
2113<td><input type='hidden' name='LDAP_BINDDN_PASS' value='$proxysettings{'LDAP_BINDDN_PASS'}'></td>
2114<td><input type='hidden' name='LDAP_GROUP' value='$proxysettings{'LDAP_GROUP'}'></td>
2115END
2116; }
2117
ed38f89d
MT
2118if (!($proxysettings{'AUTH_METHOD'} eq 'radius')) {
2119print <<END
2120<td><input type='hidden' name='RADIUS_SERVER' value='$proxysettings{'RADIUS_SERVER'}'></td>
2121<td><input type='hidden' name='RADIUS_PORT' value='$proxysettings{'RADIUS_PORT'}'></td>
2122<td><input type='hidden' name='RADIUS_IDENTIFIER' value='$proxysettings{'RADIUS_IDENTIFIER'}'></td>
2123<td><input type='hidden' name='RADIUS_SECRET' value='$proxysettings{'RADIUS_SECRET'}'></td>
2124<td><input type='hidden' name='RADIUS_ENABLE_ACL' value='$proxysettings{'RADIUS_ENABLE_ACL'}'></td>
2125<td><input type='hidden' name='RADIUS_USER_ACL' value='$proxysettings{'RADIUS_USER_ACL'}'></td>
2126<td><input type='hidden' name='RADIUS_ALLOW_USERS' value='$proxysettings{'RADIUS_ALLOW_USERS'}'></td>
2127<td><input type='hidden' name='RADIUS_DENY_USERS' value='$proxysettings{'RADIUS_DENY_USERS'}'></td>
2128END
2129; }
2130
2131print "</table>\n";
2132
2133print <<END
2134<hr size='1'>
2135END
2136;
2137
2138print <<END
2139<table width='100%'>
2140<tr>
363fb6af 2141 <td>&nbsp;</td>
ed38f89d 2142 <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
fe1656d2 2143 <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'proxy reconfigure'}' /></td>
ed38f89d 2144 <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'advproxy save and restart'}' /></td>
363fb6af
MT
2145 <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'advproxy clear cache'}' /></td>
2146 <td>&nbsp;</td>
ed38f89d
MT
2147</tr>
2148
2149</table>
2150<br />
2151<table width='100%'>
2152<tr>
e3edceeb 2153 <td><img src='/blob.gif' align='top' alt='*' />&nbsp;<font class='base'>$Lang::tr{'required field'}</font></td>
363fb6af 2154 <td align='right'>&nbsp;</td>
ed38f89d
MT
2155</tr>
2156</table>
2157</form>
2158END
2159;
2160
2161&Header::closebox();
2162
2163} else {
2164
2165# ===================================================================
2166# NCSA user management
2167# ===================================================================
2168
2169&Header::openbox('100%', 'left', "$Lang::tr{'advproxy NCSA auth'}");
2170print <<END
2171<form method='post' action='$ENV{'SCRIPT_NAME'}'>
2172<table width='100%'>
2173<tr>
363fb6af 2174 <td colspan='4'><b>$Lang::tr{'advproxy NCSA user management'}</b></td>
ed38f89d
MT
2175</tr>
2176<tr>
2177 <td width='25%' class='base'>$Lang::tr{'advproxy NCSA username'}:</td>
2178 <td width='25%'><input type='text' name='NCSA_USERNAME' value='$proxysettings{'NCSA_USERNAME'}' size='12'
2179END
2180;
153cf640 2181 if ($proxysettings{'ACTION'} eq $Lang::tr{'edit'}) { print " readonly='readonly' "; }
ed38f89d
MT
2182 print <<END
2183 /></td>
2184 <td width='25%' class='base'>$Lang::tr{'advproxy NCSA group'}:</td>
2185 <td class='base'>
2186 <select name='NCSA_GROUP'>
2187 <option value='standard' $selected{'NCSA_GROUP'}{'standard'}>$Lang::tr{'advproxy NCSA grp standard'}</option>
2188 <option value='extended' $selected{'NCSA_GROUP'}{'extended'}>$Lang::tr{'advproxy NCSA grp extended'}</option>
2189 <option value='disabled' $selected{'NCSA_GROUP'}{'disabled'}>$Lang::tr{'advproxy NCSA grp disabled'}</option>
2190 </select>
2191 </td>
2192
2193</tr>
2194<tr>
2195 <td class='base'>$Lang::tr{'advproxy NCSA password'}:</td>
2196 <td><input type='password' name='NCSA_PASS' value='$proxysettings{'NCSA_PASS'}' size='14' /></td>
2197 <td class='base'>$Lang::tr{'advproxy NCSA password confirm'}:</td>
2198 <td><input type='password' name='NCSA_PASS_CONFIRM' value='$proxysettings{'NCSA_PASS_CONFIRM'}' size='14' /></td>
2199</tr>
2200</table>
2201<br>
2202<table>
2203<tr>
2204 <td>&nbsp;</td>
2205 <td><input type='submit' name='SUBMIT' value='$ncsa_buttontext' /></td>
2206 <td><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /></td>
2207 <td><input type='hidden' name='NCSA_MIN_PASS_LEN' value='$proxysettings{'NCSA_MIN_PASS_LEN'}'></td>
2208END
2209;
2210 if ($proxysettings{'ACTION'} eq $Lang::tr{'edit'}) {
2211 print "<td><input type='reset' name='ACTION' value='$Lang::tr{'advproxy reset'}' /></td>\n";
2212 }
2213
2214print <<END
2215 <td>&nbsp;</td>
2216 <td>&nbsp;</td>
2217 <td><input type='button' name='return2main' value='$Lang::tr{'advproxy back to main page'}' onClick='self.location.href="$ENV{'SCRIPT_NAME'}"'></td>
2218</tr>
2219</table>
2220</form>
2221<hr size='1'>
2222<table width='100%'>
2223<tr>
363fb6af 2224 <td><b>$Lang::tr{'advproxy NCSA user accounts'}:</b></td>
ed38f89d
MT
2225</tr>
2226</table>
2227<table width='100%' align='center'>
2228END
2229;
2230
2231if (-e $extgrp)
2232{
2233 open(FILE, $extgrp); @grouplist = <FILE>; close(FILE);
2234 foreach $user (@grouplist) { chomp($user); push(@userlist,$user.":extended"); }
2235}
2236if (-e $stdgrp)
2237{
2238 open(FILE, $stdgrp); @grouplist = <FILE>; close(FILE);
2239 foreach $user (@grouplist) { chomp($user); push(@userlist,$user.":standard"); }
2240}
2241if (-e $disgrp)
2242{
2243 open(FILE, $disgrp); @grouplist = <FILE>; close(FILE);
2244 foreach $user (@grouplist) { chomp($user); push(@userlist,$user.":disabled"); }
2245}
2246
2247@userlist = sort(@userlist);
2248
2249# If the password file contains entries, print entries and action icons
2250
488d1b7c 2251if ( ! -z "$userdb" ) {
ed38f89d
MT
2252 print <<END
2253 <tr>
2254 <td width='30%' class='boldbase' align='center'><b><i>$Lang::tr{'advproxy NCSA username'}</i></b></td>
2255 <td width='30%' class='boldbase' align='center'><b><i>$Lang::tr{'advproxy NCSA group membership'}</i></b></td>
2256 <td class='boldbase' colspan='2' align='center'>&nbsp;</td>
2257 </tr>
2258END
2259;
2260 $id = 0;
2261 foreach $line (@userlist)
2262 {
2263 $id++;
2264 chomp($line);
2265 @temp = split(/:/,$line);
2266 if($proxysettings{'ACTION'} eq $Lang::tr{'edit'} && $proxysettings{'ID'} eq $line) {
2267 print "<tr bgcolor='$Header::colouryellow'>\n"; }
2268 elsif ($id % 2) {
4e17adad 2269 print "<tr bgcolor='$color{'color20'}'>\n"; }
ed38f89d 2270 else {
4e17adad 2271 print "<tr bgcolor='$color{'color22'}'>\n"; }
ed38f89d
MT
2272
2273 print <<END
2274 <td align='center'>$temp[0]</td>
2275 <td align='center'>
2276END
2277;
2278 if ($temp[1] eq 'standard') {
2279 print $Lang::tr{'advproxy NCSA grp standard'};
2280 } elsif ($temp[1] eq 'extended') {
2281 print $Lang::tr{'advproxy NCSA grp extended'};
2282 } elsif ($temp[1] eq 'disabled') {
2283 print $Lang::tr{'advproxy NCSA grp disabled'}; }
2284 print <<END
2285 </td>
2286 <td width='8%' align='center'>
2287 <form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'>
2288 <input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' title='$Lang::tr{'edit'}' alt='$Lang::tr{'edit'}' />
2289 <input type='hidden' name='ID' value='$line' />
2290 <input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
2291 </form>
2292 </td>
2293
2294 <td width='8%' align='center'>
2295 <form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'>
2296 <input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' title='$Lang::tr{'remove'}' alt='$Lang::tr{'remove'}' />
2297 <input type='hidden' name='ID' value='$temp[0]' />
2298 <input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
2299 </form>
2300 </td>
2301 </tr>
2302END
2303;
2304 }
2305
2306print <<END
2307</table>
2308<br>
9fb25b1c 2309<table>
ed38f89d
MT
2310<tr>
2311 <td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
2312 <td>&nbsp; &nbsp; <img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
2313 <td class='base'>$Lang::tr{'edit'}</td>
2314 <td>&nbsp; &nbsp; <img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
2315 <td class='base'>$Lang::tr{'remove'}</td>
2316</tr>
2317END
2318;
2319} else {
2320 print <<END
2321 <tr>
363fb6af 2322 <td><i>$Lang::tr{'advproxy NCSA no accounts'}</i></td>
ed38f89d
MT
2323 </tr>
2324END
2325;
2326}
2327
2328print <<END
2329</table>
2330END
2331;
2332
2333&Header::closebox();
2334
2335}
2336
2337# ===================================================================
2338
2339&Header::closebigbox();
2340
2341&Header::closepage();
2342
2343# -------------------------------------------------------------------
2344
2345sub read_acls
2346{
2347 if (-e "$acl_src_subnets") {
2348 open(FILE,"$acl_src_subnets");
2349 delete $proxysettings{'SRC_SUBNETS'};
2350 while (<FILE>) { $proxysettings{'SRC_SUBNETS'} .= $_ };
2351 close(FILE);
2352 }
2353 if (-e "$acl_src_banned_ip") {
2354 open(FILE,"$acl_src_banned_ip");
2355 delete $proxysettings{'SRC_BANNED_IP'};
2356 while (<FILE>) { $proxysettings{'SRC_BANNED_IP'} .= $_ };
2357 close(FILE);
2358 }
2359 if (-e "$acl_src_banned_mac") {
2360 open(FILE,"$acl_src_banned_mac");
2361 delete $proxysettings{'SRC_BANNED_MAC'};
2362 while (<FILE>) { $proxysettings{'SRC_BANNED_MAC'} .= $_ };
2363 close(FILE);
2364 }
2365 if (-e "$acl_src_unrestricted_ip") {
2366 open(FILE,"$acl_src_unrestricted_ip");
2367 delete $proxysettings{'SRC_UNRESTRICTED_IP'};
2368 while (<FILE>) { $proxysettings{'SRC_UNRESTRICTED_IP'} .= $_ };
2369 close(FILE);
2370 }
2371 if (-e "$acl_src_unrestricted_mac") {
2372 open(FILE,"$acl_src_unrestricted_mac");
2373 delete $proxysettings{'SRC_UNRESTRICTED_MAC'};
2374 while (<FILE>) { $proxysettings{'SRC_UNRESTRICTED_MAC'} .= $_ };
2375 close(FILE);
2376 }
2377 if (-e "$acl_dst_nocache") {
2378 open(FILE,"$acl_dst_nocache");
2379 delete $proxysettings{'DST_NOCACHE'};
2380 while (<FILE>) { $proxysettings{'DST_NOCACHE'} .= $_ };
2381 close(FILE);
2382 }
2383 if (-e "$acl_dst_noauth") {
2384 open(FILE,"$acl_dst_noauth");
2385 delete $proxysettings{'DST_NOAUTH'};
2386 while (<FILE>) { $proxysettings{'DST_NOAUTH'} .= $_ };
2387 close(FILE);
2388 }
ce1c170b
AK
2389 if (-e "$acl_dst_noproxy_ip") {
2390 open(FILE,"$acl_dst_noproxy_ip");
2391 delete $proxysettings{'DST_NOPROXY_IP'};
2392 while (<FILE>) { $proxysettings{'DST_NOPROXY_IP'} .= $_ };
2393 close(FILE);
2394 }
2395 if (-e "$acl_dst_noproxy_url") {
2396 open(FILE,"$acl_dst_noproxy_url");
2397 delete $proxysettings{'DST_NOPROXY_URL'};
2398 while (<FILE>) { $proxysettings{'DST_NOPROXY_URL'} .= $_ };
2399 close(FILE);
2400 }
363fb6af
MT
2401 if (-e "$acl_ports_safe") {
2402 open(FILE,"$acl_ports_safe");
2403 delete $proxysettings{'PORTS_SAFE'};
2404 while (<FILE>) { $proxysettings{'PORTS_SAFE'} .= $_ };
2405 close(FILE);
2406 }
2407 if (-e "$acl_ports_ssl") {
2408 open(FILE,"$acl_ports_ssl");
2409 delete $proxysettings{'PORTS_SSL'};
2410 while (<FILE>) { $proxysettings{'PORTS_SSL'} .= $_ };
2411 close(FILE);
2412 }
ed38f89d
MT
2413 if (-e "$mimetypes") {
2414 open(FILE,"$mimetypes");
2415 delete $proxysettings{'MIME_TYPES'};
2416 while (<FILE>) { $proxysettings{'MIME_TYPES'} .= $_ };
2417 close(FILE);
2418 }
ed38f89d
MT
2419 if (-e "$raddir/radauth.allowusers") {
2420 open(FILE,"$raddir/radauth.allowusers");
2421 delete $proxysettings{'RADIUS_ALLOW_USERS'};
2422 while (<FILE>) { $proxysettings{'RADIUS_ALLOW_USERS'} .= $_ };
2423 close(FILE);
2424 }
2425 if (-e "$raddir/radauth.denyusers") {
2426 open(FILE,"$raddir/radauth.denyusers");
2427 delete $proxysettings{'RADIUS_DENY_USERS'};
2428 while (<FILE>) { $proxysettings{'RADIUS_DENY_USERS'} .= $_ };
2429 close(FILE);
2430 }
2431 if (-e "$identdir/identauth.allowusers") {
2432 open(FILE,"$identdir/identauth.allowusers");
2433 delete $proxysettings{'IDENT_ALLOW_USERS'};
2434 while (<FILE>) { $proxysettings{'IDENT_ALLOW_USERS'} .= $_ };
2435 close(FILE);
2436 }
2437 if (-e "$identdir/identauth.denyusers") {
2438 open(FILE,"$identdir/identauth.denyusers");
2439 delete $proxysettings{'IDENT_DENY_USERS'};
2440 while (<FILE>) { $proxysettings{'IDENT_DENY_USERS'} .= $_ };
2441 close(FILE);
2442 }
2443 if (-e "$identhosts") {
2444 open(FILE,"$identhosts");
2445 delete $proxysettings{'IDENT_HOSTS'};
2446 while (<FILE>) { $proxysettings{'IDENT_HOSTS'} .= $_ };
2447 close(FILE);
2448 }
2449 if (-e "$cre_groups") {
2450 open(FILE,"$cre_groups");
2451 delete $proxysettings{'CRE_GROUPS'};
2452 while (<FILE>) { $proxysettings{'CRE_GROUPS'} .= $_ };
2453 close(FILE);
2454 }
2455 if (-e "$cre_svhosts") {
2456 open(FILE,"$cre_svhosts");
2457 delete $proxysettings{'CRE_SVHOSTS'};
2458 while (<FILE>) { $proxysettings{'CRE_SVHOSTS'} .= $_ };
2459 close(FILE);
2460 }
2461}
2462
2463# -------------------------------------------------------------------
2464
2465sub check_acls
2466{
363fb6af
MT
2467 @temp = split(/\n/,$proxysettings{'PORTS_SAFE'});
2468 undef $proxysettings{'PORTS_SAFE'};
2469 foreach (@temp)
2470 {
2471 s/^\s+//g; s/\s+$//g;
2472 if ($_)
2473 {
2474 $line = $_;
2475 if (/^[^#]+\s+#\sSquids\sport/) { s/(^[^#]+)(\s+#\sSquids\sport)/$proxysettings{'PROXY_PORT'}\2/; $line=$_; }
2476 s/#.*//g; s/\s+//g;
2477 if (/.*-.*-.*/) { $errormessage = $Lang::tr{'advproxy errmsg invalid destination port'}; }
2478 @templist = split(/-/);
2479 foreach (@templist) { unless (&General::validport($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid destination port'}; } }
2480 $proxysettings{'PORTS_SAFE'} .= $line."\n";
2481 }
2482 }
2483
2484 @temp = split(/\n/,$proxysettings{'PORTS_SSL'});
2485 undef $proxysettings{'PORTS_SSL'};
2486 foreach (@temp)
2487 {
2488 s/^\s+//g; s/\s+$//g;
2489 if ($_)
2490 {
2491 $line = $_;
2492 s/#.*//g; s/\s+//g;
2493 if (/.*-.*-.*/) { $errormessage = $Lang::tr{'advproxy errmsg invalid destination port'}; }
2494 @templist = split(/-/);
2495 foreach (@templist) { unless (&General::validport($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid destination port'}; } }
2496 $proxysettings{'PORTS_SSL'} .= $line."\n";
2497 }
2498 }
2499
2500 @temp = split(/\n/,$proxysettings{'DST_NOCACHE'});
2501 undef $proxysettings{'DST_NOCACHE'};
2502 foreach (@temp)
2503 {
488d1b7c
CS
2504 s/^\s+//g;
2505 unless (/^#/) { s/\s+//g; }
363fb6af
MT
2506 if ($_)
2507 {
488d1b7c 2508 if (/^\./) { $_ = '*'.$_; }
ba4f53c5 2509 unless (&General::validwildcarddomainname($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid url'} . ": " . &Header::escape($_); }
363fb6af
MT
2510 $proxysettings{'DST_NOCACHE'} .= $_."\n";
2511 }
2512 }
2513
ed38f89d
MT
2514 @temp = split(/\n/,$proxysettings{'SRC_SUBNETS'});
2515 undef $proxysettings{'SRC_SUBNETS'};
2516 foreach (@temp)
2517 {
2518 s/^\s+//g; s/\s+$//g;
2519 if ($_)
2520 {
bc464ecd 2521 unless (&Network::check_subnet($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'} . ": $_"; }
ed38f89d
MT
2522 $proxysettings{'SRC_SUBNETS'} .= $_."\n";
2523 }
2524 }
2525
2526 @temp = split(/\n/,$proxysettings{'SRC_BANNED_IP'});
2527 undef $proxysettings{'SRC_BANNED_IP'};
2528 foreach (@temp)
2529 {
2530 s/^\s+//g; s/\s+$//g;
2531 if ($_)
2532 {
2533 unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
2534 $proxysettings{'SRC_BANNED_IP'} .= $_."\n";
2535 }
2536 }
2537
2538 @temp = split(/\n/,$proxysettings{'SRC_BANNED_MAC'});
2539 undef $proxysettings{'SRC_BANNED_MAC'};
2540 foreach (@temp)
2541 {
2542 s/^\s+//g; s/\s+$//g; s/-/:/g;
2543 if ($_)
2544 {
2545 unless (&General::validmac($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid mac'}; }
2546 $proxysettings{'SRC_BANNED_MAC'} .= $_."\n";
2547 }
2548 }
2549
2550 @temp = split(/\n/,$proxysettings{'SRC_UNRESTRICTED_IP'});
2551 undef $proxysettings{'SRC_UNRESTRICTED_IP'};
2552 foreach (@temp)
2553 {
2554 s/^\s+//g; s/\s+$//g;
2555 if ($_)
2556 {
2557 unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
2558 $proxysettings{'SRC_UNRESTRICTED_IP'} .= $_."\n";
2559 }
2560 }
2561
2562 @temp = split(/\n/,$proxysettings{'SRC_UNRESTRICTED_MAC'});
2563 undef $proxysettings{'SRC_UNRESTRICTED_MAC'};
2564 foreach (@temp)
2565 {
2566 s/^\s+//g; s/\s+$//g; s/-/:/g;
2567 if ($_)
2568 {
2569 unless (&General::validmac($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid mac'}; }
2570 $proxysettings{'SRC_UNRESTRICTED_MAC'} .= $_."\n";
2571 }
2572 }
2573
363fb6af 2574 @temp = split(/\n/,$proxysettings{'DST_NOAUTH'});
37273bc6 2575 undef $proxysettings{'DST_NOAUTH'};
363fb6af
MT
2576 foreach (@temp)
2577 {
488d1b7c
CS
2578 s/^\s+//g;
2579 unless (/^#/) { s/\s+//g; }
363fb6af
MT
2580 if ($_)
2581 {
488d1b7c 2582 if (/^\./) { $_ = '*'.$_; }
363fb6af
MT
2583 $proxysettings{'DST_NOAUTH'} .= $_."\n";
2584 }
2585 }
2586
ce1c170b
AK
2587 @temp = split(/\n/,$proxysettings{'DST_NOPROXY_IP'});
2588 undef $proxysettings{'DST_NOPROXY_IP'};
2589 foreach (@temp)
2590 {
2591 s/^\s+//g; s/\s+$//g;
2592 if ($_)
2593 {
2594 unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg wpad invalid ip or mask'}; }
2595 $proxysettings{'DST_NOPROXY_IP'} .= $_."\n";
2596 }
2597 }
2598
2599 @temp = split(/\n/,$proxysettings{'DST_NOPROXY_URL'});
2600 undef $proxysettings{'DST_NOPROXY_URL'};
2601 foreach (@temp)
2602 {
2603 s/^\s+//g;
2604 unless (/^#/) { s/\s+//g; }
2605 if ($_)
2606 {
2607 if (/^\./) { $_ = '*'.$_; }
ba4f53c5 2608 unless (&General::validwildcarddomainname($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid url'} . ": " . &Header::escape($_); }
ce1c170b
AK
2609 $proxysettings{'DST_NOPROXY_URL'} .= $_."\n";
2610 }
2611 }
2612
ed38f89d
MT
2613 if (($proxysettings{'NTLM_ENABLE_ACL'} eq 'on') && ($proxysettings{'NTLM_USER_ACL'} eq 'positive'))
2614 {
2615 @temp = split(/\n/,$proxysettings{'NTLM_ALLOW_USERS'});
2616 undef $proxysettings{'NTLM_ALLOW_USERS'};
2617 foreach (@temp)
2618 {
2619 s/^\s+//g; s/\s+$//g;
2620 if ($_) { $proxysettings{'NTLM_ALLOW_USERS'} .= $_."\n"; }
2621 }
2622 if ($proxysettings{'NTLM_ALLOW_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
2623 }
2624
2625 if (($proxysettings{'NTLM_ENABLE_ACL'} eq 'on') && ($proxysettings{'NTLM_USER_ACL'} eq 'negative'))
2626 {
2627 @temp = split(/\n/,$proxysettings{'NTLM_DENY_USERS'});
2628 undef $proxysettings{'NTLM_DENY_USERS'};
2629 foreach (@temp)
2630 {
2631 s/^\s+//g; s/\s+$//g;
2632 if ($_) { $proxysettings{'NTLM_DENY_USERS'} .= $_."\n"; }
2633 }
2634 if ($proxysettings{'NTLM_DENY_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
2635 }
2636
2637 if (($proxysettings{'IDENT_ENABLE_ACL'} eq 'on') && ($proxysettings{'IDENT_USER_ACL'} eq 'positive'))
2638 {
2639 @temp = split(/\n/,$proxysettings{'IDENT_ALLOW_USERS'});
2640 undef $proxysettings{'IDENT_ALLOW_USERS'};
2641 foreach (@temp)
2642 {
2643 s/^\s+//g; s/\s+$//g;
2644 if ($_) { $proxysettings{'IDENT_ALLOW_USERS'} .= $_."\n"; }
2645 }
2646 if ($proxysettings{'IDENT_ALLOW_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
2647 }
2648
2649 if (($proxysettings{'IDENT_ENABLE_ACL'} eq 'on') && ($proxysettings{'IDENT_USER_ACL'} eq 'negative'))
2650 {
2651 @temp = split(/\n/,$proxysettings{'IDENT_DENY_USERS'});
2652 undef $proxysettings{'IDENT_DENY_USERS'};
2653 foreach (@temp)
2654 {
2655 s/^\s+//g; s/\s+$//g;
2656 if ($_) { $proxysettings{'IDENT_DENY_USERS'} .= $_."\n"; }
2657 }
2658 if ($proxysettings{'IDENT_DENY_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
2659 }
2660
2661 if (($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on') && ($proxysettings{'RADIUS_USER_ACL'} eq 'positive'))
2662 {
2663 @temp = split(/\n/,$proxysettings{'RADIUS_ALLOW_USERS'});
2664 undef $proxysettings{'RADIUS_ALLOW_USERS'};
2665 foreach (@temp)
2666 {
2667 s/^\s+//g; s/\s+$//g;
2668 if ($_) { $proxysettings{'RADIUS_ALLOW_USERS'} .= $_."\n"; }
2669 }
2670 if ($proxysettings{'RADIUS_ALLOW_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
2671 }
2672
2673 if (($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on') && ($proxysettings{'RADIUS_USER_ACL'} eq 'negative'))
2674 {
2675 @temp = split(/\n/,$proxysettings{'RADIUS_DENY_USERS'});
2676 undef $proxysettings{'RADIUS_DENY_USERS'};
2677 foreach (@temp)
2678 {
2679 s/^\s+//g; s/\s+$//g;
2680 if ($_) { $proxysettings{'RADIUS_DENY_USERS'} .= $_."\n"; }
2681 }
2682 if ($proxysettings{'RADIUS_DENY_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
2683 }
2684
2685 @temp = split(/\n/,$proxysettings{'IDENT_HOSTS'});
2686 undef $proxysettings{'IDENT_HOSTS'};
2687 foreach (@temp)
2688 {
2689 s/^\s+//g; s/\s+$//g;
2690 if ($_)
2691 {
2692 unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
2693 $proxysettings{'IDENT_HOSTS'} .= $_."\n";
2694 }
2695 }
2696
2697 @temp = split(/\n/,$proxysettings{'CRE_SVHOSTS'});
2698 undef $proxysettings{'CRE_SVHOSTS'};
2699 foreach (@temp)
2700 {
2701 s/^\s+//g; s/\s+$//g;
2702 if ($_)
2703 {
2704 unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
2705 $proxysettings{'CRE_SVHOSTS'} .= $_."\n";
2706 }
2707 }
2708}
2709
ed38f89d
MT
2710# -------------------------------------------------------------------
2711
2712sub write_acls
2713{
2714 open(FILE, ">$acl_src_subnets");
2715 flock(FILE, 2);
363fb6af
MT
2716 if (!$proxysettings{'SRC_SUBNETS'})
2717 {
ee4b5bbb
MT
2718 if (&Header::green_used()) {
2719 print FILE "$green_cidr\n";
2720 }
2721
2722 if (&Header::blue_used()) {
f09a0af5 2723 print FILE "$blue_cidr\n";
363fb6af
MT
2724 }
2725 } else { print FILE $proxysettings{'SRC_SUBNETS'}; }
ed38f89d
MT
2726 close(FILE);
2727
2728 open(FILE, ">$acl_src_banned_ip");
2729 flock(FILE, 2);
2730 print FILE $proxysettings{'SRC_BANNED_IP'};
2731 close(FILE);
2732
2733 open(FILE, ">$acl_src_banned_mac");
2734 flock(FILE, 2);
2735 print FILE $proxysettings{'SRC_BANNED_MAC'};
2736 close(FILE);
2737
2738 open(FILE, ">$acl_src_unrestricted_ip");
2739 flock(FILE, 2);
2740 print FILE $proxysettings{'SRC_UNRESTRICTED_IP'};
2741 close(FILE);
2742
2743 open(FILE, ">$acl_src_unrestricted_mac");
2744 flock(FILE, 2);
2745 print FILE $proxysettings{'SRC_UNRESTRICTED_MAC'};
2746 close(FILE);
2747
488d1b7c
CS
2748 open(FILE, ">$acl_dst_noauth");
2749 flock(FILE, 2);
2750 print FILE $proxysettings{'DST_NOAUTH'};
2751 close(FILE);
2752
ce1c170b
AK
2753 open(FILE, ">$acl_dst_noproxy_ip");
2754 flock(FILE, 2);
2755 print FILE $proxysettings{'DST_NOPROXY_IP'};
2756 close(FILE);
2757
2758 open(FILE, ">$acl_dst_noproxy_url");
2759 flock(FILE, 2);
2760 print FILE $proxysettings{'DST_NOPROXY_URL'};
2761 close(FILE);
2762
488d1b7c
CS
2763 open(FILE, ">$acl_dst_noauth_net");
2764 close(FILE);
2765 open(FILE, ">$acl_dst_noauth_dom");
2766 close(FILE);
2767 open(FILE, ">$acl_dst_noauth_url");
2768 close(FILE);
2769
2770 @temp = split(/\n/,$proxysettings{'DST_NOAUTH'});
2771 foreach(@temp)
2772 {
2773 unless (/^#/)
2774 {
2775 if (/^\*\.\w/)
2776 {
2777 s/^\*//;
2778 open(FILE, ">>$acl_dst_noauth_dom");
2779 flock(FILE, 2);
2780 print FILE "$_\n";
2781 close(FILE);
2782 }
2783 elsif (&General::validipormask($_))
2784 {
2785 open(FILE, ">>$acl_dst_noauth_net");
2786 flock(FILE, 2);
2787 print FILE "$_\n";
2788 close(FILE);
2789 }
2790 elsif (/\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?-\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?/)
2791 {
2792 open(FILE, ">>$acl_dst_noauth_net");
2793 flock(FILE, 2);
2794 print FILE "$_\n";
2795 close(FILE);
2796 }
2797 else
2798 {
2799 open(FILE, ">>$acl_dst_noauth_url");
2800 flock(FILE, 2);
2801 if (/^[fh]tt?ps?:\/\//) { print FILE "$_\n"; } else { print FILE "^[fh]tt?ps?://$_\n"; }
2802 close(FILE);
2803 }
2804 }
2805 }
2806
ed38f89d
MT
2807 open(FILE, ">$acl_dst_nocache");
2808 flock(FILE, 2);
2809 print FILE $proxysettings{'DST_NOCACHE'};
2810 close(FILE);
2811
488d1b7c
CS
2812 open(FILE, ">$acl_dst_nocache_net");
2813 close(FILE);
2814 open(FILE, ">$acl_dst_nocache_dom");
2815 close(FILE);
2816 open(FILE, ">$acl_dst_nocache_url");
ed38f89d
MT
2817 close(FILE);
2818
488d1b7c
CS
2819 @temp = split(/\n/,$proxysettings{'DST_NOCACHE'});
2820 foreach(@temp)
2821 {
2822 unless (/^#/)
2823 {
2824 if (/^\*\.\w/)
2825 {
2826 s/^\*//;
2827 open(FILE, ">>$acl_dst_nocache_dom");
2828 flock(FILE, 2);
2829 print FILE "$_\n";
2830 close(FILE);
2831 }
2832 elsif (&General::validipormask($_))
2833 {
2834 open(FILE, ">>$acl_dst_nocache_net");
2835 flock(FILE, 2);
2836 print FILE "$_\n";
2837 close(FILE);
2838 }
2839 elsif (/\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?-\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?/)
2840 {
2841 open(FILE, ">>$acl_dst_nocache_net");
2842 flock(FILE, 2);
2843 print FILE "$_\n";
2844 close(FILE);
2845 }
2846 else
2847 {
2848 open(FILE, ">>$acl_dst_nocache_url");
2849 flock(FILE, 2);
2850 if (/^[fh]tt?ps?:\/\//) { print FILE "$_\n"; } else { print FILE "^[fh]tt?ps?://$_\n"; }
2851 close(FILE);
2852 }
2853 }
2854 }
2855
363fb6af
MT
2856 open(FILE, ">$acl_ports_safe");
2857 flock(FILE, 2);
2858 if (!$proxysettings{'PORTS_SAFE'}) { print FILE $def_ports_safe; } else { print FILE $proxysettings{'PORTS_SAFE'}; }
2859 close(FILE);
2860
2861 open(FILE, ">$acl_ports_ssl");
2862 flock(FILE, 2);
2863 if (!$proxysettings{'PORTS_SSL'}) { print FILE $def_ports_ssl; } else { print FILE $proxysettings{'PORTS_SSL'}; }
2864 close(FILE);
2865
ed38f89d
MT
2866 if (-s $throttled_urls)
2867 {
2868 open(URLFILE, $throttled_urls);
2869 @temp = <URLFILE>;
2870 close(URLFILE);
363fb6af 2871 foreach (@temp) { print FILE; }
ed38f89d
MT
2872 }
2873 close(FILE);
2874
2875 open(FILE, ">$mimetypes");
2876 flock(FILE, 2);
2877 print FILE $proxysettings{'MIME_TYPES'};
2878 close(FILE);
2879
ed38f89d
MT
2880 open(FILE, ">$raddir/radauth.allowusers");
2881 flock(FILE, 2);
2882 print FILE $proxysettings{'RADIUS_ALLOW_USERS'};
2883 close(FILE);
2884
2885 open(FILE, ">$raddir/radauth.denyusers");
2886 flock(FILE, 2);
2887 print FILE $proxysettings{'RADIUS_DENY_USERS'};
2888 close(FILE);
2889
2890 open(FILE, ">$identdir/identauth.allowusers");
2891 flock(FILE, 2);
2892 print FILE $proxysettings{'IDENT_ALLOW_USERS'};
2893 close(FILE);
2894
2895 open(FILE, ">$identdir/identauth.denyusers");
2896 flock(FILE, 2);
2897 print FILE $proxysettings{'IDENT_DENY_USERS'};
2898 close(FILE);
2899
2900 open(FILE, ">$identhosts");
2901 flock(FILE, 2);
2902 print FILE $proxysettings{'IDENT_HOSTS'};
2903 close(FILE);
2904
2905 open(FILE, ">$cre_groups");
2906 flock(FILE, 2);
2907 print FILE $proxysettings{'CRE_GROUPS'};
2908 close(FILE);
2909
2910 open(FILE, ">$cre_svhosts");
2911 flock(FILE, 2);
2912 print FILE $proxysettings{'CRE_SVHOSTS'};
2913 close(FILE);
2914}
2915
2916# -------------------------------------------------------------------
2917
2918sub writepacfile
2919{
bf2a1c52
OF
2920 my %vpnconfig=();
2921 my %ovpnconfig=();
2922 &General::readhasharray("${General::swroot}/vpn/config", \%vpnconfig);
2923 &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%ovpnconfig);
22527178 2924 open(FILE, ">/srv/web/ipfire/html/proxy.pac");
ed38f89d
MT
2925 flock(FILE, 2);
2926 print FILE "function FindProxyForURL(url, host)\n";
2927 print FILE "{\n";
2928 if (($proxysettings{'ENABLE'} eq 'on') || ($proxysettings{'ENABLE_BLUE'} eq 'on'))
2929 {
2930 print FILE <<END
2931if (
2932 (isPlainHostName(host)) ||
c03cf9ea 2933 (isInNet(host, "127.0.0.1", "255.0.0.0")) ||
7c1b7d3e
BB
2934END
2935;
2936
2937 if ($netsettings{'GREEN_DEV'}) {
2938 print FILE " (isInNet(host, \"$netsettings{'GREEN_NETADDRESS'}\", \"$netsettings{'GREEN_NETMASK'}\")) ||\n";
2939 }
2940
2941 if (&Header::blue_used() && $netsettings{'BLUE_DEV'}) {
2942 print FILE " (isInNet(host, \"$netsettings{'BLUE_NETADDRESS'}\", \"$netsettings{'BLUE_NETMASK'}\")) ||\n";
2943 }
2944
2945 if (&Header::orange_used() && $netsettings{'ORANGE_DEV'}) {
2946 print FILE " (isInNet(host, \"$netsettings{'ORANGE_NETADDRESS'}\", \"$netsettings{'ORANGE_NETMASK'}\")) ||\n";
2947 }
2948
ddc5602a
AK
2949 # Additional exceptions for URLs
2950 # The file has to be created by the user and should contain one entry per line
2951 # Line-Format: <URL incl. wildcards>
ce1c170b 2952 # e.g. *.ipfire.org*
ddc5602a
AK
2953 if (-s "$acl_dst_noproxy_url") {
2954 undef @templist;
2955
2956 open(NOPROXY,"$acl_dst_noproxy_url");
2957 @templist = <NOPROXY>;
2958 close(NOPROXY);
2959 chomp (@templist);
2960
2961 foreach (@templist)
2962 {
2963 print FILE " (shExpMatch(url, \"$_\")) ||\n";
2964 }
2965 }
2966
2967 # Additional exceptions for Subnets
2968 # The file has to be created by the user and should contain one entry per line
ce1c170b
AK
2969 # Line-Format: <IP>/<SUBNET MASK>
2970 # e.g. 192.168.0.0/255.255.255.0
ddc5602a
AK
2971 if (-s "$acl_dst_noproxy_ip") {
2972 undef @templist;
2973
2974 open(NOPROXY,"$acl_dst_noproxy_ip");
2975 @templist = <NOPROXY>;
2976 close(NOPROXY);
2977 chomp (@templist);
2978
2979 foreach (@templist)
2980 {
ce1c170b
AK
2981 @temp = split(/\//);
2982 print FILE " (isInNet(host, \"$temp[0]\", \"$temp[1]\")) ||\n";
ddc5602a
AK
2983 }
2984 }
2985
bf2a1c52
OF
2986 foreach my $key (sort { uc($vpnconfig{$a}[1]) cmp uc($vpnconfig{$b}[1]) } keys %vpnconfig) {
2987 if ($vpnconfig{$key}[0] eq 'on' && $vpnconfig{$key}[3] ne 'host') {
2988 my @networks = split(/\|/, $vpnconfig{$key}[11]);
2989 foreach my $network (@networks) {
2990 my ($vpnip, $vpnsub) = split("/", $network);
2991 $vpnsub = &Network::convert_prefix2netmask($vpnsub) || $vpnsub;
2992 print FILE " (isInNet(host, \"$vpnip\", \"$vpnsub\")) ||\n";
2993 }
2994 }
2995 }
2996
2997 foreach my $key (sort { uc($ovpnconfig{$a}[1]) cmp uc($ovpnconfig{$b}[1]) } keys %ovpnconfig) {
2998 if ($ovpnconfig{$key}[0] eq 'on' && $ovpnconfig{$key}[3] ne 'host') {
2999 my @networks = split(/\|/, $ovpnconfig{$key}[11]);
3000 foreach my $network (@networks) {
3001 my ($vpnip, $vpnsub) = split("/", $network);
3002 print FILE " (isInNet(host, \"$vpnip\", \"$vpnsub\")) ||\n";
3003 }
3004 }
3005 }
3006
7c1b7d3e 3007 print FILE <<END
488d1b7c 3008 (isInNet(host, "169.254.0.0", "255.255.0.0"))
ed38f89d
MT
3009 )
3010 return "DIRECT";
3011
3012 else
3013
3014END
3015;
3016 if ($proxysettings{'ENABLE'} eq 'on')
3017 {
268292e7
CS
3018 print FILE "if (\n";
3019 print FILE " (isInNet(myIpAddress(), \"$netsettings{'GREEN_NETADDRESS'}\", \"$netsettings{'GREEN_NETMASK'}\"))";
3020
3021 undef @templist;
3022 if (-e "$acl_src_subnets") {
3023 open(SUBNETS,"$acl_src_subnets");
3024 @templist = <SUBNETS>;
3025 close(SUBNETS);
3026 }
3027
3028 foreach (@templist)
3029 {
3030 @temp = split(/\//);
3031 if (
28c9dec6 3032 ($temp[0] ne $netsettings{'GREEN_NETADDRESS'}) && ($temp[1] ne $netsettings{'GREEN_NETMASK'}) &&
268292e7
CS
3033 ($temp[0] ne $netsettings{'BLUE_NETADDRESS'}) && ($temp[1] ne $netsettings{'BLUE_NETMASK'})
3034 )
3035 {
3036 chomp $temp[1];
badd010f
SK
3037 my $tempmask = &Network::convert_prefix2netmask($temp[1]);
3038 print FILE " ||\n (isInNet(myIpAddress(), \"$temp[0]\", \"$tempmask\"))";
268292e7
CS
3039 }
3040 }
3041
3042 print FILE "\n";
3043
ed38f89d 3044 print FILE <<END
ed38f89d
MT
3045 )
3046 return "PROXY $netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}";
3047END
3048;
3049 }
3050 if (($proxysettings{'ENABLE'} eq 'on') && ($proxysettings{'ENABLE_BLUE'} eq 'on') && ($netsettings{'BLUE_DEV'}))
3051 {
3052 print FILE "\n else\n\n";
3053 }
3054 if (($netsettings{'BLUE_DEV'}) && ($proxysettings{'ENABLE_BLUE'} eq 'on'))
3055 {
3056 print FILE <<END
3057if (
3058 (isInNet(myIpAddress(), "$netsettings{'BLUE_NETADDRESS'}", "$netsettings{'BLUE_NETMASK'}"))
3059 )
3060 return "PROXY $netsettings{'BLUE_ADDRESS'}:$proxysettings{'PROXY_PORT'}";
3061END
3062;
3063 }
3064 }
3065 print FILE "}\n";
3066 close(FILE);
3067}
3068
3069# -------------------------------------------------------------------
3070
3071sub writeconfig
3072{
3073 my $authrealm;
3074 my $delaypools;
3075
363fb6af 3076 if ($proxysettings{'THROTTLING_GREEN_TOTAL'} +
ed38f89d
MT
3077 $proxysettings{'THROTTLING_GREEN_HOST'} +
3078 $proxysettings{'THROTTLING_BLUE_TOTAL'} +
3079 $proxysettings{'THROTTLING_BLUE_HOST'} gt 0)
3080 {
3081 $delaypools = 1; } else { $delaypools = 0;
3082 }
3083
3084 if ($proxysettings{'AUTH_REALM'} eq '')
3085 {
d12aede7 3086 $authrealm = "IPFire Advanced Proxy Server";
ed38f89d
MT
3087 } else {
3088 $authrealm = $proxysettings{'AUTH_REALM'};
3089 }
3090
3091 $_ = $proxysettings{'UPSTREAM_PROXY'};
69491545 3092 my ($remotehost, $remoteport) = split(/:/,$_);
ed38f89d
MT
3093
3094 if ($remoteport eq '') { $remoteport = 80; }
3095
3096 open(FILE, ">${General::swroot}/proxy/squid.conf");
3097 flock(FILE, 2);
3098 print FILE <<END
363fb6af
MT
3099# Do not modify '${General::swroot}/proxy/squid.conf' directly since any changes
3100# you make will be overwritten whenever you resave proxy settings using the
3101# web interface!
3102#
3103# Instead, modify the file '$acl_include' and
3104# then restart the proxy service using the web interface. Changes made to the
3105# 'include.acl' file will propagate to the 'squid.conf' file at that time.
3106
ed38f89d
MT
3107shutdown_lifetime 5 seconds
3108icp_port 0
13aeb192 3109httpd_suppress_version_string on
ed38f89d 3110
ed38f89d
MT
3111END
3112 ;
8b417dd1
MT
3113
3114 # Include file with user defined settings.
3115 if (-e "/etc/squid/squid.conf.pre.local") {
3116 print FILE "include /etc/squid/squid.conf.pre.local\n\n";
3117 }
3118
ee4b5bbb
MT
3119 if (&Header::green_used()) {
3120 print FILE "http_port $netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}";
3121 } else {
3122 print FILE "http_port 0.0.0.0:$proxysettings{'PROXY_PORT'}";
3123 }
363fb6af
MT
3124 if ($proxysettings{'NO_CONNECTION_AUTH'} eq 'on') { print FILE " no-connection-auth" }
3125 print FILE "\n";
3126
ee4b5bbb 3127 if (&Header::green_used() && $proxysettings{'TRANSPARENT'} eq 'on') {
0f6b6067
MT
3128 print FILE "http_port $netsettings{'GREEN_ADDRESS'}:$proxysettings{'TRANSPARENT_PORT'} intercept";
3129 if ($proxysettings{'NO_CONNECTION_AUTH'} eq 'on') { print FILE " no-connection-auth" }
3130 print FILE "\n";
3131 }
3132
ed38f89d 3133 if ($netsettings{'BLUE_DEV'} && $proxysettings{'ENABLE_BLUE'} eq 'on') {
363fb6af 3134 print FILE "http_port $netsettings{'BLUE_ADDRESS'}:$proxysettings{'PROXY_PORT'}";
363fb6af
MT
3135 if ($proxysettings{'NO_CONNECTION_AUTH'} eq 'on') { print FILE " no-connection-auth" }
3136 print FILE "\n";
0f6b6067
MT
3137
3138 if ($proxysettings{'TRANSPARENT_BLUE'} eq 'on') {
3139 print FILE "http_port $netsettings{'BLUE_ADDRESS'}:$proxysettings{'TRANSPARENT_PORT'} intercept";
3140 if ($proxysettings{'NO_CONNECTION_AUTH'} eq 'on') { print FILE " no-connection-auth" }
3141 print FILE "\n";
3142 }
ed38f89d
MT
3143 }
3144
53d67554 3145 if (($proxysettings{'CACHE_SIZE'} > 0) || ($proxysettings{'CACHE_MEM'} > 0))
488d1b7c
CS
3146 {
3147 print FILE "\n";
ed38f89d 3148
488d1b7c
CS
3149 if (!-z $acl_dst_nocache_dom) {
3150 print FILE "acl no_cache_domains dstdomain \"$acl_dst_nocache_dom\"\n";
3151 print FILE "cache deny no_cache_domains\n";
3152 }
3153 if (!-z $acl_dst_nocache_net) {
37273bc6 3154 print FILE "acl no_cache_ipaddr dst \"$acl_dst_nocache_net\"\n";
488d1b7c
CS
3155 print FILE "cache deny no_cache_ipaddr\n";
3156 }
3157 if (!-z $acl_dst_nocache_url) {
3158 print FILE "acl no_cache_hosts url_regex -i \"$acl_dst_nocache_url\"\n";
3159 print FILE "cache deny no_cache_hosts\n";
3160 }
ed38f89d
MT
3161 }
3162
3163 print FILE <<END
3164
3165cache_effective_user squid
363fb6af 3166umask 022
ed38f89d
MT
3167
3168pid_filename /var/run/squid.pid
3169
3170cache_mem $proxysettings{'CACHE_MEM'} MB
ed38f89d
MT
3171END
3172 ;
ab4a5a35 3173 print FILE "error_directory $errordir/$proxysettings{'ERR_LANGUAGE'}\n\n";
363fb6af 3174
ed38f89d 3175 if ($proxysettings{'OFFLINE_MODE'} eq 'on') { print FILE "offline_mode on\n\n"; }
6bea848d 3176 if ($proxysettings{'CACHE_DIGESTS'} eq 'on') { print FILE "digest_generation on\n\n"; } else { print FILE "digest_generation off\n\n"; }
c4b12981 3177
ed38f89d
MT
3178 if ((!($proxysettings{'MEM_POLICY'} eq 'LRU')) || (!($proxysettings{'CACHE_POLICY'} eq 'LRU')))
3179 {
3180 if (!($proxysettings{'MEM_POLICY'} eq 'LRU'))
3181 {
3182 print FILE "memory_replacement_policy $proxysettings{'MEM_POLICY'}\n";
3183 }
3184 if (!($proxysettings{'CACHE_POLICY'} eq 'LRU'))
3185 {
3186 print FILE "cache_replacement_policy $proxysettings{'CACHE_POLICY'}\n";
3187 }
3188 print FILE "\n";
3189 }
3190
8fbcf730
MT
3191 open (PORTS,"$acl_ports_ssl");
3192 my @ssl_ports = <PORTS>;
3193 close PORTS;
3194
3195 if (@ssl_ports) {
3196 foreach (@ssl_ports) {
3197 print FILE "acl SSL_ports port $_";
3198 }
3199 }
3200
3201 open (PORTS,"$acl_ports_safe");
3202 my @safe_ports = <PORTS>;
3203 close PORTS;
3204
3205 if (@safe_ports) {
3206 foreach (@safe_ports) {
3207 print FILE "acl Safe_ports port $_";
3208 }
3209 }
3210
ee4b5bbb
MT
3211 print FILE <<END;
3212acl IPFire_ips dst 127.0.0.1
8fbcf730
MT
3213acl IPFire_http port $http_port
3214acl IPFire_https port $https_port
8fbcf730
MT
3215acl IPFire_networks src "$acl_src_subnets"
3216acl IPFire_servers dst "$acl_src_subnets"
ee4b5bbb
MT
3217END
3218 if (&Header::green_used()) {
3219 print FILE <<END;
3220acl IPFire_ips dst $netsettings{'GREEN_ADDRESS'}
8fbcf730
MT
3221acl IPFire_green_network src $green_cidr
3222acl IPFire_green_servers dst $green_cidr
3223END
ee4b5bbb 3224 }
8fbcf730
MT
3225 if ($netsettings{'BLUE_DEV'}) { print FILE "acl IPFire_blue_network src $blue_cidr\n"; }
3226 if ($netsettings{'BLUE_DEV'}) { print FILE "acl IPFire_blue_servers dst $blue_cidr\n"; }
3227 if (!-z $acl_src_banned_ip) { print FILE "acl IPFire_banned_ips src \"$acl_src_banned_ip\"\n"; }
3228 if (!-z $acl_src_banned_mac) { print FILE "acl IPFire_banned_mac arp \"$acl_src_banned_mac\"\n"; }
3229 if (!-z $acl_src_unrestricted_ip) { print FILE "acl IPFire_unrestricted_ips src \"$acl_src_unrestricted_ip\"\n"; }
3230 if (!-z $acl_src_unrestricted_mac) { print FILE "acl IPFire_unrestricted_mac arp \"$acl_src_unrestricted_mac\"\n"; }
3231 print FILE <<END
3232acl CONNECT method CONNECT
3233END
3234 ;
3235
f0b7534f
MT
3236 if ($proxysettings{'CACHE_SIZE'} > 0) {
3237 print FILE <<END
3238maximum_object_size $proxysettings{'MAX_SIZE'} KB
3239minimum_object_size $proxysettings{'MIN_SIZE'} KB
3240
3241cache_dir aufs /var/log/cache $proxysettings{'CACHE_SIZE'} $proxysettings{'L1_DIRS'} 256
3242END
3243 ;
3244 } else {
53d67554
DWD
3245 if ($proxysettings{'CACHE_MEM'} > 0) {
3246 # always 2% of CACHE_MEM defined as max object size
3247 print FILE "maximum_object_size_in_memory " . int($proxysettings{'CACHE_MEM'} * 1024 * 0.02) . " KB\n\n";
3248 } else {
3249 print FILE "cache deny all\n\n";
3250 }
f0b7534f
MT
3251 }
3252
3253 print FILE <<END
3254request_body_max_size $proxysettings{'MAX_OUTGOING_SIZE'} KB
3255END
3256 ;
3257
3258 if ($proxysettings{'MAX_INCOMING_SIZE'} > 0) {
3259 if (!-z $acl_src_unrestricted_ip) { print FILE "reply_body_max_size none IPFire_unrestricted_ips\n"; }
3260 if (!-z $acl_src_unrestricted_mac) { print FILE "reply_body_max_size none IPFire_unrestricted_mac\n"; }
3261 if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
3262 {
3263 if (!-z $extgrp) { print FILE "reply_body_max_size none for_extended_users\n"; }
3264 }
3265 }
3266
3267 if ( $proxysettings{'MAX_INCOMING_SIZE'} != '0' )
e7b7cbae 3268 {
f0b7534f 3269 print FILE "reply_body_max_size $proxysettings{'MAX_INCOMING_SIZE'} KB all\n\n";
e7b7cbae
AF
3270 }
3271
ed38f89d
MT
3272 if ($proxysettings{'LOGGING'} eq 'on')
3273 {
363fb6af 3274 print FILE <<END
754f508b 3275access_log stdio:/var/log/squid/access.log
ed38f89d
MT
3276cache_log /var/log/squid/cache.log
3277cache_store_log none
3278END
3279 ;
754f508b 3280 if ($proxysettings{'LOGUSERAGENT'} eq 'on') { print FILE "access_log stdio:\/var\/log\/squid\/user_agent.log useragent\n"; }
ed38f89d
MT
3281 if ($proxysettings{'LOGQUERY'} eq 'on') { print FILE "\nstrip_query_terms off\n"; }
3282 } else {
3283 print FILE <<END
363fb6af 3284access_log /dev/null
ed38f89d
MT
3285cache_log /dev/null
3286cache_store_log none
3287END
3288 ;}
3289 print FILE <<END
3290
3291log_mime_hdrs off
3292END
3293 ;
3294
3295 if ($proxysettings{'FORWARD_IPADDRESS'} eq 'on')
3296 {
363fb6af 3297 print FILE "forwarded_for on\n";
ed38f89d 3298 } else {
363fb6af 3299 print FILE "forwarded_for off\n";
ed38f89d 3300 }
363fb6af
MT
3301 if ($proxysettings{'FORWARD_VIA'} eq 'on')
3302 {
3303 print FILE "via on\n";
3304 } else {
3305 print FILE "via off\n";
3306 }
3307 print FILE "\n";
ed38f89d
MT
3308
3309 if ((!($proxysettings{'AUTH_METHOD'} eq 'none')) && (!($proxysettings{'AUTH_METHOD'} eq 'ident')))
3310 {
3311 if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
3312 {
754f508b 3313 print FILE "auth_param basic program $authdir/basic_ncsa_auth $userdb\n";
ed38f89d
MT
3314 print FILE "auth_param basic children $proxysettings{'AUTH_CHILDREN'}\n";
3315 print FILE "auth_param basic realm $authrealm\n";
3316 print FILE "auth_param basic credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n";
0f8251fe 3317 if (!($proxysettings{'AUTH_IPCACHE_TTL'} eq '0')) { print FILE "\nauthenticate_ip_ttl $proxysettings{'AUTH_IPCACHE_TTL'} minutes\n"; }
ed38f89d
MT
3318 }
3319
3320 if ($proxysettings{'AUTH_METHOD'} eq 'ldap')
3321 {
725e3869 3322 print FILE "auth_param basic utf8 on\n";
754f508b 3323 print FILE "auth_param basic program $authdir/basic_ldap_auth -b \"$proxysettings{'LDAP_BASEDN'}\"";
ed38f89d
MT
3324 if (!($proxysettings{'LDAP_BINDDN_USER'} eq '')) { print FILE " -D \"$proxysettings{'LDAP_BINDDN_USER'}\""; }
3325 if (!($proxysettings{'LDAP_BINDDN_PASS'} eq '')) { print FILE " -w $proxysettings{'LDAP_BINDDN_PASS'}"; }
3326 if ($proxysettings{'LDAP_TYPE'} eq 'ADS')
3327 {
3328 if ($proxysettings{'LDAP_GROUP'} eq '')
3329 {
3330 print FILE " -f \"(\&(objectClass=person)(sAMAccountName=\%s))\"";
3331 } else {
3332 print FILE " -f \"(\&(\&(objectClass=person)(sAMAccountName=\%s))(memberOf=$proxysettings{'LDAP_GROUP'}))\"";
3333 }
3334 print FILE " -u sAMAccountName -P";
3335 }
3336 if ($proxysettings{'LDAP_TYPE'} eq 'NDS')
3337 {
3338 if ($proxysettings{'LDAP_GROUP'} eq '')
3339 {
3340 print FILE " -f \"(\&(objectClass=person)(cn=\%s))\"";
3341 } else {
3342 print FILE " -f \"(\&(\&(objectClass=person)(cn=\%s))(groupMembership=$proxysettings{'LDAP_GROUP'}))\"";
3343 }
3344 print FILE " -u cn -P";
3345 }
3346 if (($proxysettings{'LDAP_TYPE'} eq 'V2') || ($proxysettings{'LDAP_TYPE'} eq 'V3'))
3347 {
3348 if ($proxysettings{'LDAP_GROUP'} eq '')
3349 {
3350 print FILE " -f \"(\&(objectClass=person)(uid=\%s))\"";
3351 } else {
3352 print FILE " -f \"(\&(\&(objectClass=person)(uid=\%s))(memberOf=$proxysettings{'LDAP_GROUP'}))\"";
3353 }
3354 if ($proxysettings{'LDAP_TYPE'} eq 'V2') { print FILE " -v 2"; }
3355 if ($proxysettings{'LDAP_TYPE'} eq 'V3') { print FILE " -v 3"; }
3356 print FILE " -u uid -P";
3357 }
3358 print FILE " $proxysettings{'LDAP_SERVER'}:$proxysettings{'LDAP_PORT'}\n";
3359 print FILE "auth_param basic children $proxysettings{'AUTH_CHILDREN'}\n";
3360 print FILE "auth_param basic realm $authrealm\n";
3361 print FILE "auth_param basic credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n";
0f8251fe 3362 if (!($proxysettings{'AUTH_IPCACHE_TTL'} eq '0')) { print FILE "\nauthenticate_ip_ttl $proxysettings{'AUTH_IPCACHE_TTL'} minutes\n"; }
ed38f89d
MT
3363 }
3364
603248db
MT
3365 if ($proxysettings{'AUTH_METHOD'} eq 'ntlm-auth')
3366 {
b5674643
MT
3367 print FILE "auth_param ntlm program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp";
3368 if ($proxysettings{'NTLM_AUTH_GROUP'}) {
3369 my $ntlm_auth_group = $proxysettings{'NTLM_AUTH_GROUP'};
3370 $ntlm_auth_group =~ s/\\/\+/;
3371
a44eed25 3372 print FILE " --require-membership-of=$ntlm_auth_group";
b5674643
MT
3373 }
3374 print FILE "\n";
3375
2fc5124b 3376 print FILE "auth_param ntlm children $proxysettings{'AUTH_CHILDREN'}\n\n";
a1018d86 3377 print FILE "auth_param ntlm credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n\n";
2fc5124b
MT
3378
3379 # BASIC authentication
3380 if ($proxysettings{'NTLM_AUTH_BASIC'} eq "on") {
3381 print FILE "auth_param basic program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-basic";
3382 if ($proxysettings{'NTLM_AUTH_GROUP'}) {
3383 my $ntlm_auth_group = $proxysettings{'NTLM_AUTH_GROUP'};
3384 $ntlm_auth_group =~ s/\\/\+/;
3385
a44eed25 3386 print FILE " --require-membership-of=$ntlm_auth_group";
2fc5124b
MT
3387 }
3388 print FILE "\n";
fa286b13 3389 print FILE "auth_param basic children $proxysettings{'AUTH_CHILDREN'}\n";
5c2a76f7 3390 print FILE "auth_param basic realm $authrealm\n";
6df2d528 3391 print FILE "auth_param basic credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n\n";
2fc5124b 3392 }
603248db
MT
3393 }
3394
ed38f89d
MT
3395 if ($proxysettings{'AUTH_METHOD'} eq 'radius')
3396 {
754f508b 3397 print FILE "auth_param basic program $authdir/basic_radius_auth -h $proxysettings{'RADIUS_SERVER'} -p $proxysettings{'RADIUS_PORT'} ";
ed38f89d
MT
3398 if (!($proxysettings{'RADIUS_IDENTIFIER'} eq '')) { print FILE "-i $proxysettings{'RADIUS_IDENTIFIER'} "; }
3399 print FILE "-w $proxysettings{'RADIUS_SECRET'}\n";
3400 print FILE "auth_param basic children $proxysettings{'AUTH_CHILDREN'}\n";
3401 print FILE "auth_param basic realm $authrealm\n";
3402 print FILE "auth_param basic credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n";
0f8251fe 3403 if (!($proxysettings{'AUTH_IPCACHE_TTL'} eq '0')) { print FILE "\nauthenticate_ip_ttl $proxysettings{'AUTH_IPCACHE_TTL'} minutes\n"; }
ed38f89d
MT
3404 }
3405
3406 print FILE "\n";
3407 print FILE "acl for_inetusers proxy_auth REQUIRED\n";
ed38f89d
MT
3408 if (($proxysettings{'AUTH_METHOD'} eq 'radius') && ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on'))
3409 {
3410 if ((!-z "$raddir/radauth.allowusers") && ($proxysettings{'RADIUS_USER_ACL'} eq 'positive'))
3411 {
3412 print FILE "acl for_acl_users proxy_auth \"$raddir/radauth.allowusers\"\n";
3413 }
3414 if ((!-z "$raddir/radauth.denyusers") && ($proxysettings{'RADIUS_USER_ACL'} eq 'negative'))
3415 {
3416 print FILE "acl for_acl_users proxy_auth \"$raddir/radauth.denyusers\"\n";
3417 }
3418 }
3419 if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
3420 {
3421 print FILE "\n";
3422 if (!-z $extgrp) { print FILE "acl for_extended_users proxy_auth \"$extgrp\"\n"; }
3423 if (!-z $disgrp) { print FILE "acl for_disabled_users proxy_auth \"$disgrp\"\n"; }
3424 }
3425 if (!($proxysettings{'AUTH_MAX_USERIP'} eq '')) { print FILE "\nacl concurrent max_user_ip -s $proxysettings{'AUTH_MAX_USERIP'}\n"; }
3426 print FILE "\n";
3427
488d1b7c
CS
3428 if (!-z $acl_dst_noauth_net) { print FILE "acl to_ipaddr_without_auth dst \"$acl_dst_noauth_net\"\n"; }
3429 if (!-z $acl_dst_noauth_dom) { print FILE "acl to_domains_without_auth dstdomain \"$acl_dst_noauth_dom\"\n"; }
3430 if (!-z $acl_dst_noauth_url) { print FILE "acl to_hosts_without_auth url_regex -i \"$acl_dst_noauth_url\"\n"; }
363fb6af 3431 print FILE "\n";
488d1b7c 3432
ed38f89d
MT
3433 }
3434
3435 if ($proxysettings{'AUTH_METHOD'} eq 'ident')
3436 {
3437 if ($proxysettings{'IDENT_REQUIRED'} eq 'on')
3438 {
3439 print FILE "acl for_inetusers ident REQUIRED\n";
3440 }
3441 if ($proxysettings{'IDENT_ENABLE_ACL'} eq 'on')
3442 {
3443 if ((!-z "$identdir/identauth.allowusers") && ($proxysettings{'IDENT_USER_ACL'} eq 'positive'))
3444 {
3445 print FILE "acl for_acl_users ident_regex -i \"$identdir/identauth.allowusers\"\n\n";
3446 }
3447 if ((!-z "$identdir/identauth.denyusers") && ($proxysettings{'IDENT_USER_ACL'} eq 'negative'))
3448 {
3449 print FILE "acl for_acl_users ident_regex -i \"$identdir/identauth.denyusers\"\n\n";
3450 }
3451 }
488d1b7c
CS
3452 if (!-z $acl_dst_noauth_net) { print FILE "acl to_ipaddr_without_auth dst \"$acl_dst_noauth_net\"\n"; }
3453 if (!-z $acl_dst_noauth_dom) { print FILE "acl to_domains_without_auth dstdomain \"$acl_dst_noauth_dom\"\n"; }
3454 if (!-z $acl_dst_noauth_url) { print FILE "acl to_hosts_without_auth url_regex -i \"$acl_dst_noauth_url\"\n"; }
363fb6af 3455 print FILE "\n";
ed38f89d
MT
3456 }
3457
3458 if (($delaypools) && (!-z $acl_dst_throttle)) { print FILE "acl for_throttled_urls url_regex -i \"$acl_dst_throttle\"\n\n"; }
3459
28c9dec6 3460 print FILE "acl within_timeframe time ";
ed38f89d
MT
3461 if ($proxysettings{'TIME_MON'} eq 'on') { print FILE "M"; }
3462 if ($proxysettings{'TIME_TUE'} eq 'on') { print FILE "T"; }
3463 if ($proxysettings{'TIME_WED'} eq 'on') { print FILE "W"; }
3464 if ($proxysettings{'TIME_THU'} eq 'on') { print FILE "H"; }
3465 if ($proxysettings{'TIME_FRI'} eq 'on') { print FILE "F"; }
3466 if ($proxysettings{'TIME_SAT'} eq 'on') { print FILE "A"; }
3467 if ($proxysettings{'TIME_SUN'} eq 'on') { print FILE "S"; }
363fb6af
MT
3468 print FILE " $proxysettings{'TIME_FROM_HOUR'}:";
3469 print FILE "$proxysettings{'TIME_FROM_MINUTE'}-";
3470 print FILE "$proxysettings{'TIME_TO_HOUR'}:";
3471 print FILE "$proxysettings{'TIME_TO_MINUTE'}\n\n";
ed38f89d
MT
3472
3473 if ((!-z $mimetypes) && ($proxysettings{'ENABLE_MIME_FILTER'} eq 'on')) {
3474 print FILE "acl blocked_mimetypes rep_mime_type \"$mimetypes\"\n\n";
3475 }
3476
ed38f89d
MT
3477 if ($proxysettings{'CLASSROOM_EXT'} eq 'on') {
3478 print FILE <<END
3479
3480#Classroom extensions
488d1b7c
CS
3481acl IPFire_no_access_ips src "$acl_src_noaccess_ip"
3482acl IPFire_no_access_mac arp "$acl_src_noaccess_mac"
ed38f89d
MT
3483END
3484 ;
3485 print FILE "deny_info ";
ab4a5a35 3486 if (($proxysettings{'ERR_DESIGN'} eq 'squid') && (-e "$errordir/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED"))
363fb6af
MT
3487 {
3488 print FILE "ERR_ACCESS_DISABLED";
3489 } else {
3490 print FILE "ERR_ACCESS_DENIED";
3491 }
488d1b7c 3492 print FILE " IPFire_no_access_ips\n";
ed38f89d 3493 print FILE "deny_info ";
ab4a5a35 3494 if (($proxysettings{'ERR_DESIGN'} eq 'squid') && (-e "$errordir/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED"))
363fb6af
MT
3495 {
3496 print FILE "ERR_ACCESS_DISABLED";
3497 } else {
3498 print FILE "ERR_ACCESS_DENIED";
3499 }
488d1b7c 3500 print FILE " IPFire_no_access_mac\n";
ed38f89d
MT
3501
3502 print FILE <<END
488d1b7c
CS
3503http_access deny IPFire_no_access_ips
3504http_access deny IPFire_no_access_mac
ed38f89d
MT
3505END
3506 ;
3507 }
3508
363fb6af
MT
3509 #Insert acl file and replace __VAR__ with correct values
3510 my $blue_net = ''; #BLUE empty by default
3511 my $blue_ip = '';
3512 if ($netsettings{'BLUE_DEV'} && $proxysettings{'ENABLE_BLUE'} eq 'on') {
f09a0af5 3513 $blue_net = "$blue_cidr";
363fb6af
MT
3514 $blue_ip = "$netsettings{'BLUE_ADDRESS'}";
3515 }
3516 if (!-z $acl_include)
ed38f89d
MT
3517 {
3518 open (ACL, "$acl_include");
488d1b7c 3519 print FILE "\n#Start of custom includes\n\n";
ed38f89d
MT
3520 while (<ACL>) {
3521 $_ =~ s/__GREEN_IP__/$netsettings{'GREEN_ADDRESS'}/;
f09a0af5 3522 $_ =~ s/__GREEN_NET__/$green_cidr/;
ed38f89d
MT
3523 $_ =~ s/__BLUE_IP__/$blue_ip/;
3524 $_ =~ s/__BLUE_NET__/$blue_net/;
363fb6af 3525 $_ =~ s/__PROXY_PORT__/$proxysettings{'PROXY_PORT'}/;
ed38f89d
MT
3526 print FILE $_;
3527 }
e0be9eab 3528 print FILE "\n#End of custom includes\n\n";
ed38f89d
MT
3529 close (ACL);
3530 }
e0be9eab
MF
3531
3532 print FILE <<END
3533# Prevent ipv6 requests to avoid crash in squid > 5.x
3534acl to_ipv6 dst ipv6
3535acl from_ipv6 src ipv6
3536http_access deny to_ipv6
3537http_access deny from_ipv6
3538END
3539 ;
3540
ed38f89d 3541 if ((!-z $extgrp) && ($proxysettings{'AUTH_METHOD'} eq 'ncsa') && ($proxysettings{'NCSA_BYPASS_REDIR'} eq 'on')) { print FILE "\nredirector_access deny for_extended_users\n"; }
dfee7582
SS
3542
3543 # Check if squidclamav is enabled.
3544 if ($proxysettings{'ENABLE_CLAMAV'} eq 'on') {
3545 print FILE "\n#Settings for squidclamav:\n";
0f6b6067 3546 print FILE "http_port 127.0.0.1:$proxysettings{'PROXY_PORT'}\n";
dfee7582
SS
3547 print FILE "acl purge method PURGE\n";
3548 print FILE "http_access deny to_localhost\n";
3549 print FILE "http_access allow localhost\n";
3550 print FILE "http_access allow purge localhost\n";
3551 print FILE "http_access deny purge\n";
3552 print FILE "url_rewrite_access deny localhost\n";
3553 }
3ebc0da7 3554 print FILE <<END;
ed38f89d
MT
3555
3556#Access to squid:
3557#local machine, no restriction
3558http_access allow localhost
3559
3560#GUI admin if local machine connects
488d1b7c
CS
3561http_access allow IPFire_ips IPFire_networks IPFire_http
3562http_access allow CONNECT IPFire_ips IPFire_networks IPFire_https
ed38f89d
MT
3563
3564#Deny not web services
ed38f89d 3565END
3ebc0da7
MT
3566
3567if (@safe_ports) {
3568 print FILE "http_access deny !Safe_ports\n";
3569}
3570
3571if (@ssl_ports) {
3572 print FILE "http_access deny CONNECT !SSL_ports\n";
3573}
ed38f89d 3574
bb5ca283
PM
3575 if ((($proxysettings{'ASNBL_FASTFLUX_DETECTION'} eq 'on') && (!-z $proxysettings{'ASNBL_FASTFLUX_THRESHOLD'})) || ($proxysettings{'ASNBL_SELECANN_DETECTION'} eq 'on')) {
3576 print FILE "external_acl_type asnblhelper children-max=10 children-startup=2 ttl=86400 %DST /usr/bin/asnbl-helper.py ${General::swroot}/proxy/asnbl-helper.conf\n";
3577 print FILE "acl asnbl external asnblhelper\n";
3578
3579 # Use the user-defined URL filter whitelist (if present and populated) for the ASNBL helper as well
3580 # Necessary for destinations such as fedoraproject.org, but we do not want to maintain a dedicated
3581 # or hardcoded list for such FQDNs.
3582 if ((-e "${General::swroot}/urlfilter/blacklists/custom/allowed/domains") && (!-z "${General::swroot}/urlfilter/blacklists/custom/allowed/domains")) {
3583 print FILE "acl asnbl_whitelisted_destinations dstdomain \"${General::swroot}/urlfilter/blacklists/custom/allowed/domains\"\n";
3584 print FILE "http_access deny asnbl !asnbl_whitelisted_destinations\n\n";
3585 } else {
3586 print FILE "http_access deny asnbl\n\n";
3587 }
3588
3589 # Write ASNBL helper configuration file...
3590 open(ASNBLFILE, ">${General::swroot}/proxy/asnbl-helper.conf");
3591 flock(ASNBLFILE, 2);
3592
3593 print ASNBLFILE<<END
3594#
3595# This file has been automatically generated. Manual changes will be overwritten.
3596#
3597
3598[GENERAL]
3599LOGLEVEL = INFO
3600ASNDB_PATH = /var/lib/location/database.db
3601USE_REPLYMAP = no
3602END
3603;
3604
3605 print ASNBLFILE "AS_DIVERSITY_THRESHOLD = $proxysettings{'ASNBL_FASTFLUX_THRESHOLD'}\n";
3606
3607 if ($proxysettings{'ASNBL_SELECANN_DETECTION'} eq 'on') {
3608 print ASNBLFILE "BLOCK_SUSPECTED_SELECTIVE_ANNOUNCEMENTS = yes\n";
3609 } else {
3610 print ASNBLFILE "BLOCK_SUSPECTED_SELECTIVE_ANNOUNCEMENTS = no\n";
3611 }
3612
3613 if ($proxysettings{'ASNBL_FASTFLUX_DETECTION'} eq 'on') {
3614 print ASNBLFILE "BLOCK_DIVERSITY_EXCEEDING_DESTINATIONS = yes\n";
3615 } else {
3616 print ASNBLFILE "BLOCK_DIVERSITY_EXCEEDING_DESTINATIONS = no\n";
3617 }
3618
3619 print ASNBLFILE<<END
3620TESTDATA = (10.0.0.1, 0) (127.0.0.1, 0) (fe80::1, 0)
66c36198 3621ACTIVE_ASNBLS =
bb5ca283
PM
3622END
3623;
3624
3625 close ASNBLFILE;
3626 }
3627
ed38f89d
MT
3628if ($proxysettings{'AUTH_METHOD'} eq 'ident')
3629{
3630print FILE "#Set ident ACLs\n";
3631if (!-z $identhosts)
3632 {
3633 print FILE "acl on_ident_aware_hosts src \"$identhosts\"\n";
3634 print FILE "ident_lookup_access allow on_ident_aware_hosts\n";
3635 print FILE "ident_lookup_access deny all\n";
3636 } else {
3637 print FILE "ident_lookup_access allow all\n";
3638 }
3639 print FILE "ident_timeout $proxysettings{'IDENT_TIMEOUT'} seconds\n\n";
3640}
3641
3642if ($delaypools) {
3643 print FILE "#Set download throttling\n";
3644
3645 if ($netsettings{'BLUE_DEV'})
3646 {
3647 print FILE "delay_pools 2\n";
3648 } else {
3649 print FILE "delay_pools 1\n";
3650 }
3651
3652 print FILE "delay_class 1 3\n";
3653 if ($netsettings{'BLUE_DEV'}) { print FILE "delay_class 2 3\n"; }
3654
3655 print FILE "delay_parameters 1 ";
3656 if ($proxysettings{'THROTTLING_GREEN_TOTAL'} eq 'unlimited')
3657 {
3658 print FILE "-1/-1";
3659 } else {
3660 print FILE $proxysettings{'THROTTLING_GREEN_TOTAL'} * 125;
3661 print FILE "/";
3662 print FILE $proxysettings{'THROTTLING_GREEN_TOTAL'} * 250;
3663 }
3664
3665 print FILE " -1/-1 ";
3666 if ($proxysettings{'THROTTLING_GREEN_HOST'} eq 'unlimited')
3667 {
3668 print FILE "-1/-1";
3669 } else {
3670 print FILE $proxysettings{'THROTTLING_GREEN_HOST'} * 125;
3671 print FILE "/";
3672 print FILE $proxysettings{'THROTTLING_GREEN_HOST'} * 250;
3673 }
3674 print FILE "\n";
3675
3676 if ($netsettings{'BLUE_DEV'})
3677 {
3678 print FILE "delay_parameters 2 ";
3679 if ($proxysettings{'THROTTLING_BLUE_TOTAL'} eq 'unlimited')
3680 {
3681 print FILE "-1/-1";
3682 } else {
3683 print FILE $proxysettings{'THROTTLING_BLUE_TOTAL'} * 125;
3684 print FILE "/";
3685 print FILE $proxysettings{'THROTTLING_BLUE_TOTAL'} * 250;
3686 }
3687 print FILE " -1/-1 ";
3688 if ($proxysettings{'THROTTLING_BLUE_HOST'} eq 'unlimited')
3689 {
3690 print FILE "-1/-1";
3691 } else {
3692 print FILE $proxysettings{'THROTTLING_BLUE_HOST'} * 125;
3693 print FILE "/";
3694 print FILE $proxysettings{'THROTTLING_BLUE_HOST'} * 250;
3695 }
3696 print FILE "\n";
3697 }
3698
488d1b7c
CS
3699 print FILE "delay_access 1 deny IPFire_ips\n";
3700 if (!-z $acl_src_unrestricted_ip) { print FILE "delay_access 1 deny IPFire_unrestricted_ips\n"; }
3701 if (!-z $acl_src_unrestricted_mac) { print FILE "delay_access 1 deny IPFire_unrestricted_mac\n"; }
ed38f89d
MT
3702 if (($proxysettings{'AUTH_METHOD'} eq 'ncsa') && (!-z $extgrp)) { print FILE "delay_access 1 deny for_extended_users\n"; }
3703
3704 if ($netsettings{'BLUE_DEV'})
3705 {
ee4b5bbb
MT
3706 if (&Header::green_used()) {
3707 print FILE "delay_access 1 allow IPFire_green_network";
3708 if (!-z $acl_dst_throttle) { print FILE " for_throttled_urls"; }
3709 print FILE "\n";
3710 }
ed38f89d
MT
3711 print FILE "delay_access 1 deny all\n";
3712 } else {
3713 print FILE "delay_access 1 allow all";
363fb6af 3714 if (!-z $acl_dst_throttle) { print FILE " for_throttled_urls"; }
ed38f89d
MT
3715 print FILE "\n";
3716 }
3717
3718 if ($netsettings{'BLUE_DEV'})
3719 {
488d1b7c
CS
3720 print FILE "delay_access 2 deny IPFire_ips\n";
3721 if (!-z $acl_src_unrestricted_ip) { print FILE "delay_access 2 deny IPFire_unrestricted_ips\n"; }
3722 if (!-z $acl_src_unrestricted_mac) { print FILE "delay_access 2 deny IPFire_unrestricted_mac\n"; }
ed38f89d 3723 if (($proxysettings{'AUTH_METHOD'} eq 'ncsa') && (!-z $extgrp)) { print FILE "delay_access 2 deny for_extended_users\n"; }
488d1b7c 3724 print FILE "delay_access 2 allow IPFire_blue_network";
363fb6af 3725 if (!-z $acl_dst_throttle) { print FILE " for_throttled_urls"; }
ed38f89d
MT
3726 print FILE "\n";
3727 print FILE "delay_access 2 deny all\n";
3728 }
3729
28c9dec6 3730 print FILE "delay_initial_bucket_level 100\n";
ed38f89d
MT
3731 print FILE "\n";
3732}
9fb25b1c 3733
ee4b5bbb 3734if (&Header::green_used() && $proxysettings{'NO_PROXY_LOCAL'} eq 'on')
9fb25b1c 3735{
b34fdcae
AF
3736 print FILE "#Prevent internal proxy access to Green except IPFire itself\n";
3737 print FILE "http_access deny IPFire_green_servers !IPFire_ips !IPFire_green_network\n\n";
9fb25b1c
MT
3738}
3739
3740if ($proxysettings{'NO_PROXY_LOCAL_BLUE'} eq 'on')
3741{
b34fdcae 3742 print FILE "#Prevent internal proxy access from Blue except IPFire itself\n";
488d1b7c 3743 print FILE "http_access allow IPFire_blue_network IPFire_blue_servers\n";
b34fdcae 3744 print FILE "http_access deny IPFire_blue_network !IPFire_ips IPFire_servers\n\n";
9fb25b1c
MT
3745}
3746
ed38f89d
MT
3747 print FILE <<END
3748#Set custom configured ACLs
3749END
3750 ;
488d1b7c
CS
3751 if (!-z $acl_src_banned_ip) { print FILE "http_access deny IPFire_banned_ips\n"; }
3752 if (!-z $acl_src_banned_mac) { print FILE "http_access deny IPFire_banned_mac\n"; }
ed38f89d
MT
3753
3754 if ((!-z $acl_dst_noauth) && (!($proxysettings{'AUTH_METHOD'} eq 'none')))
3755 {
3756 if (!-z $acl_src_unrestricted_ip)
3757 {
488d1b7c
CS
3758 if (!-z $acl_dst_noauth_net) { print FILE "http_access allow IPFire_unrestricted_ips to_ipaddr_without_auth\n"; }
3759 if (!-z $acl_dst_noauth_dom) { print FILE "http_access allow IPFire_unrestricted_ips to_domains_without_auth\n"; }
3760 if (!-z $acl_dst_noauth_url) { print FILE "http_access allow IPFire_unrestricted_ips to_hosts_without_auth\n"; }
ed38f89d
MT
3761 }
3762 if (!-z $acl_src_unrestricted_mac)
3763 {
488d1b7c
CS
3764 if (!-z $acl_dst_noauth_net) { print FILE "http_access allow IPFire_unrestricted_mac to_ipaddr_without_auth\n"; }
3765 if (!-z $acl_dst_noauth_dom) { print FILE "http_access allow IPFire_unrestricted_mac to_domains_without_auth\n"; }
3766 if (!-z $acl_dst_noauth_url) { print FILE "http_access allow IPFire_unrestricted_mac to_hosts_without_auth\n"; }
3767 }
3768 if (!-z $acl_dst_noauth_net)
3769 {
3770 print FILE "http_access allow IPFire_networks";
3771 if ($proxysettings{'TIME_ACCESS_MODE'} eq 'deny') {
3772 print FILE " !within_timeframe";
3773 } else {
3774 print FILE " within_timeframe"; }
488d1b7c
CS
3775 print FILE " to_ipaddr_without_auth\n";
3776 }
3777 if (!-z $acl_dst_noauth_dom)
3778 {
3779 print FILE "http_access allow IPFire_networks";
3780 if ($proxysettings{'TIME_ACCESS_MODE'} eq 'deny') {
3781 print FILE " !within_timeframe";
3782 } else {
3783 print FILE " within_timeframe"; }
488d1b7c
CS
3784 print FILE " to_domains_without_auth\n";
3785 }
3786 if (!-z $acl_dst_noauth_url)
3787 {
3788 print FILE "http_access allow IPFire_networks";
3789 if ($proxysettings{'TIME_ACCESS_MODE'} eq 'deny') {
3790 print FILE " !within_timeframe";
3791 } else {
3792 print FILE " within_timeframe"; }
488d1b7c 3793 print FILE " to_hosts_without_auth\n";
ed38f89d 3794 }
ed38f89d
MT
3795 }
3796
3797 if (($proxysettings{'AUTH_METHOD'} eq 'ident') && ($proxysettings{'IDENT_REQUIRED'} eq 'on') && ($proxysettings{'AUTH_ALWAYS_REQUIRED'} eq 'on'))
3798 {
3799 print FILE "http_access deny !for_inetusers";
3800 if (!-z $identhosts) { print FILE " on_ident_aware_hosts"; }
3801 print FILE "\n";
3802 }
3803
3804 if (
3805 ($proxysettings{'AUTH_METHOD'} eq 'ident') &&
3806 ($proxysettings{'AUTH_ALWAYS_REQUIRED'} eq 'on') &&
3807 ($proxysettings{'IDENT_ENABLE_ACL'} eq 'on') &&
3808 ($proxysettings{'IDENT_USER_ACL'} eq 'negative') &&
3809 (!-z "$identdir/identauth.denyusers")
3810 )
3811 {
3812 print FILE "http_access deny for_acl_users";
3813 if (($proxysettings{'AUTH_METHOD'} eq 'ident') && (!-z "$identdir/hosts")) { print FILE " on_ident_aware_hosts"; }
3814 print FILE "\n";
3815 }
3816
3817 if (!-z $acl_src_unrestricted_ip)
3818 {
488d1b7c 3819 print FILE "http_access allow IPFire_unrestricted_ips";
ed38f89d
MT
3820 if ($proxysettings{'AUTH_ALWAYS_REQUIRED'} eq 'on')
3821 {
3822 if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
3823 {
3824 if (!-z $disgrp) { print FILE " !for_disabled_users"; } else { print FILE " for_inetusers"; }
3825 }
ea72700a 3826 if (($proxysettings{'AUTH_METHOD'} eq 'ldap') || ($proxysettings{'AUTH_METHOD'} eq 'radius'))
ed38f89d
MT
3827 {
3828 print FILE " for_inetusers";
3829 }
ed38f89d 3830 if (($proxysettings{'AUTH_METHOD'} eq 'radius') && ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on'))
363fb6af 3831 {
ed38f89d 3832 if ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on')
363fb6af 3833 {
ed38f89d
MT
3834 if (($proxysettings{'RADIUS_USER_ACL'} eq 'positive') && (!-z "$raddir/radauth.allowusers"))
3835 {
3836 print FILE " for_acl_users";
3837 }
3838 if (($proxysettings{'RADIUS_USER_ACL'} eq 'negative') && (!-z "$raddir/radauth.denyusers"))
3839 {
3840 print FILE " !for_acl_users";
3841 }
3842 } else { print FILE " for_inetusers"; }
3843 }
3844 }
3845 print FILE "\n";
3846 }
3847
3848 if (!-z $acl_src_unrestricted_mac)
3849 {
488d1b7c 3850 print FILE "http_access allow IPFire_unrestricted_mac";
ed38f89d
MT
3851 if ($proxysettings{'AUTH_ALWAYS_REQUIRED'} eq 'on')
3852 {
3853 if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
3854 {
3855 if (!-z $disgrp) { print FILE " !for_disabled_users"; } else { print FILE " for_inetusers"; }
3856 }
ea72700a 3857 if (($proxysettings{'AUTH_METHOD'} eq 'ldap') || ($proxysettings{'AUTH_METHOD'} eq 'radius'))
ed38f89d
MT
3858 {
3859 print FILE " for_inetusers";
3860 }
ed38f89d 3861 if (($proxysettings{'AUTH_METHOD'} eq 'radius') && ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on'))
363fb6af 3862 {
ed38f89d 3863 if ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on')
363fb6af 3864 {
ed38f89d
MT
3865 if (($proxysettings{'RADIUS_USER_ACL'} eq 'positive') && (!-z "$raddir/radauth.allowusers"))
3866 {
3867 print FILE " for_acl_users";
3868 }
3869 if (($proxysettings{'RADIUS_USER_ACL'} eq 'negative') && (!-z "$raddir/radauth.denyusers"))
3870 {
3871 print FILE " !for_acl_users";
3872 }
3873 } else { print FILE " for_inetusers"; }
3874 }
3875 }
3876 print FILE "\n";
3877 }
3878
3879 if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
3880 {
3881 if (!-z $disgrp) { print FILE "http_access deny for_disabled_users\n"; }
488d1b7c 3882 if (!-z $extgrp) { print FILE "http_access allow IPFire_networks for_extended_users\n"; }
ed38f89d
MT
3883 }
3884
3885 if (
ed38f89d
MT
3886 (
3887 ($proxysettings{'AUTH_METHOD'} eq 'radius') &&
3888 ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on') &&
3889 ($proxysettings{'RADIUS_USER_ACL'} eq 'negative') &&
3890 (!-z "$raddir/radauth.denyusers")
3891 )
3892 ||
3893 (
3894 ($proxysettings{'AUTH_METHOD'} eq 'ident') &&
3895 ($proxysettings{'AUTH_ALWAYS_REQUIRED'} eq 'off') &&
3896 ($proxysettings{'IDENT_ENABLE_ACL'} eq 'on') &&
3897 ($proxysettings{'IDENT_USER_ACL'} eq 'negative') &&
3898 (!-z "$identdir/identauth.denyusers")
3899 )
3900 )
3901 {
3902 print FILE "http_access deny for_acl_users";
3903 if (($proxysettings{'AUTH_METHOD'} eq 'ident') && (!-z "$identdir/hosts")) { print FILE " on_ident_aware_hosts"; }
3904 print FILE "\n";
3905 }
3906
3907 if (($proxysettings{'AUTH_METHOD'} eq 'ident') && ($proxysettings{'IDENT_REQUIRED'} eq 'on') && (!-z "$identhosts"))
3908 {
3909 print FILE "http_access allow";
3910 if ($proxysettings{'TIME_ACCESS_MODE'} eq 'deny') {
3911 print FILE " !within_timeframe";
3912 } else {
3913 print FILE " within_timeframe"; }
ed38f89d
MT
3914 print FILE " !on_ident_aware_hosts\n";
3915 }
3916
488d1b7c 3917 print FILE "http_access allow IPFire_networks";
ed38f89d 3918 if (
ed38f89d
MT
3919 (
3920 ($proxysettings{'AUTH_METHOD'} eq 'radius') &&
3921 ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on') &&
3922 ($proxysettings{'RADIUS_USER_ACL'} eq 'positive') &&
3923 (!-z "$raddir/radauth.allowusers")
3924 )
3925 ||
3926 (
3927 ($proxysettings{'AUTH_METHOD'} eq 'ident') &&
3928 ($proxysettings{'IDENT_REQUIRED'} eq 'on') &&
3929 ($proxysettings{'IDENT_ENABLE_ACL'} eq 'on') &&
3930 ($proxysettings{'IDENT_USER_ACL'} eq 'positive') &&
3931 (!-z "$identdir/identauth.allowusers")
3932 )
3933 )
3934 {
3935 print FILE " for_acl_users";
3936 } elsif (((!($proxysettings{'AUTH_METHOD'} eq 'none')) && (!($proxysettings{'AUTH_METHOD'} eq 'ident'))) ||
3937 (($proxysettings{'AUTH_METHOD'} eq 'ident') && ($proxysettings{'IDENT_REQUIRED'} eq 'on'))) {
3938 print FILE " for_inetusers";
3939 }
3940 if ((!($proxysettings{'AUTH_MAX_USERIP'} eq '')) && (!($proxysettings{'AUTH_METHOD'} eq 'none')) && (!($proxysettings{'AUTH_METHOD'} eq 'ident')))
3941 {
3942 print FILE " !concurrent";
3943 }
3944 if ($proxysettings{'TIME_ACCESS_MODE'} eq 'deny') {
3945 print FILE " !within_timeframe";
3946 } else {
3947 print FILE " within_timeframe"; }
ed38f89d
MT
3948 print FILE "\n";
3949
3950 print FILE "http_access deny all\n\n";
3951
6323e908 3952 if (($proxysettings{'FORWARD_IPADDRESS'} eq 'off') || ($proxysettings{'FORWARD_VIA'} eq 'off'))
ed38f89d
MT
3953 {
3954 print FILE "#Strip HTTP Header\n";
3955
3956 if ($proxysettings{'FORWARD_IPADDRESS'} eq 'off')
3957 {
30793ae1
AF
3958 print FILE "request_header_access X-Forwarded-For deny all\n";
3959 print FILE "reply_header_access X-Forwarded-For deny all\n";
ed38f89d
MT
3960 }
3961 if ($proxysettings{'FORWARD_VIA'} eq 'off')
3962 {
30793ae1
AF
3963 print FILE "request_header_access Via deny all\n";
3964 print FILE "reply_header_access Via deny all\n";
ed38f89d 3965 }
ed38f89d
MT
3966
3967 print FILE "\n";
3968
ed38f89d
MT
3969 }
3970
3971 if ((!-z $mimetypes) && ($proxysettings{'ENABLE_MIME_FILTER'} eq 'on')) {
488d1b7c
CS
3972 if (!-z $acl_src_unrestricted_ip) { print FILE "http_reply_access allow IPFire_unrestricted_ips\n"; }
3973 if (!-z $acl_src_unrestricted_mac) { print FILE "http_reply_access allow IPFire_unrestricted_mac\n"; }
ed38f89d
MT
3974 if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
3975 {
3976 if (!-z $extgrp) { print FILE "http_reply_access allow for_extended_users\n"; }
3977 }
3978 print FILE "http_reply_access deny blocked_mimetypes\n";
3979 print FILE "http_reply_access allow all\n\n";
3980 }
3981
ed38f89d
MT
3982 print FILE "visible_hostname";
3983 if ($proxysettings{'VISIBLE_HOSTNAME'} eq '')
3984 {
3985 print FILE " $mainsettings{'HOSTNAME'}.$mainsettings{'DOMAINNAME'}\n\n";
3986 } else {
3987 print FILE " $proxysettings{'VISIBLE_HOSTNAME'}\n\n";
3988 }
3989
fe1656d2
CS
3990 if (!($proxysettings{'ADMIN_MAIL_ADDRESS'} eq '')) { print FILE "cache_mgr $proxysettings{'ADMIN_MAIL_ADDRESS'}\n"; }
3991 if (!($proxysettings{'ADMIN_PASSWORD'} eq '')) { print FILE "cachemgr_passwd $proxysettings{'ADMIN_PASSWORD'} all\n"; }
3992 print FILE "\n";
3993
3994 print FILE "max_filedescriptors $proxysettings{'FILEDESCRIPTORS'}\n\n";
ed38f89d
MT
3995
3996 # Write the parent proxy info, if needed.
3997 if ($remotehost ne '')
3998 {
ed38f89d 3999 print FILE "cache_peer $remotehost parent $remoteport 3130 default no-query";
363fb6af
MT
4000
4001 # Enter authentication for the parent cache. Option format is
4002 # login=user:password ($proxy1='YES')
4003 # login=PASS ($proxy1='PASS')
4004 # login=*:password ($proxysettings{'FORWARD_USERNAME'} eq 'on')
4005 if (($proxy1 eq 'YES') || ($proxy1 eq 'PASS'))
4006 {
4007 print FILE " login=$proxysettings{'UPSTREAM_USER'}";
4008 if ($proxy1 eq 'YES') { print FILE ":$proxysettings{'UPSTREAM_PASSWORD'}"; }
ed38f89d 4009 }
363fb6af
MT
4010 elsif ($proxysettings{'FORWARD_USERNAME'} eq 'on') { print FILE " login=*:password"; }
4011
488d1b7c
CS
4012 print FILE "\nalways_direct allow IPFire_ips\n";
4013 print FILE "never_direct allow all\n\n";
ed38f89d 4014 }
3900a6c7 4015 if (($proxysettings{'ENABLE_FILTER'} eq 'on') || ($proxysettings{'ENABLE_UPDXLRATOR'} eq 'on') || ($proxysettings{'ENABLE_CLAMAV'} eq 'on'))
363fb6af
MT
4016 {
4017 print FILE "url_rewrite_program /usr/sbin/redirect_wrapper\n";
eedca6e3
MT
4018 print FILE "url_rewrite_children ", &General::number_cpu_cores();
4019 print FILE " startup=", &General::number_cpu_cores();
4020 print FILE " idle=", &General::number_cpu_cores();
4021 print FILE " queue-size=", &General::number_cpu_cores() * 32, "\n\n";
ed38f89d 4022 }
eb3b93cc
MT
4023
4024 # Include file with user defined settings.
4025 if (-e "/etc/squid/squid.conf.local") {
4026 print FILE "include /etc/squid/squid.conf.local\n";
4027 }
ed38f89d 4028 close FILE;
dfee7582
SS
4029
4030 # Proxy settings for squidclamav - if installed.
4031 #
4032 # Check if squidclamav is enabled.
4033 if ($proxysettings{'ENABLE_CLAMAV'} eq 'on') {
4034
4035 my $configfile='/etc/squidclamav.conf';
4036
4037 my $data = &General::read_file_utf8($configfile);
4038 $data =~ s/squid_port [0-9]+/squid_port $proxysettings{'PROXY_PORT'}/g;
4039 &General::write_file_utf8($configfile, $data);
4040 }
ed38f89d
MT
4041}
4042
4043# -------------------------------------------------------------------
4044
4045sub adduser
4046{
4047 my ($str_user, $str_pass, $str_group) = @_;
4048 my @groupmembers=();
4049
4050 if ($str_pass eq 'lEaVeAlOnE')
4051 {
4052 open(FILE, "$userdb");
4053 @groupmembers = <FILE>;
4054 close(FILE);
4055 foreach $line (@groupmembers) { if ($line =~ /^$str_user:/i) { $str_pass = substr($line,index($line,":")); } }
4056 &deluser($str_user);
4057 open(FILE, ">>$userdb");
4058 flock FILE,2;
4059 print FILE "$str_user$str_pass";
4060 close(FILE);
4061 } else {
4062 &deluser($str_user);
0aff7b81 4063
77ea7462
SS
4064 my %htpasswd_options = (
4065 passwdFile => "$userdb",
4066 UseMD5 => 1,
4067 );
4068
4069 my $htpasswd = new Apache::Htpasswd(\%htpasswd_options);
4070
0aff7b81 4071 $htpasswd->htpasswd($str_user, $str_pass);
ed38f89d
MT
4072 }
4073
4074 if ($str_group eq 'standard') { open(FILE, ">>$stdgrp");
4075 } elsif ($str_group eq 'extended') { open(FILE, ">>$extgrp");
4076 } elsif ($str_group eq 'disabled') { open(FILE, ">>$disgrp"); }
4077 flock FILE, 2;
4078 print FILE "$str_user\n";
4079 close(FILE);
4080
4081 return;
4082}
4083
4084# -------------------------------------------------------------------
4085
4086sub deluser
4087{
4088 my ($str_user) = @_;
4089 my $groupfile='';
4090 my @groupmembers=();
4091 my @templist=();
4092
4093 foreach $groupfile ($stdgrp, $extgrp, $disgrp)
4094 {
4095 undef @templist;
4096 open(FILE, "$groupfile");
4097 @groupmembers = <FILE>;
4098 close(FILE);
4099 foreach $line (@groupmembers) { if (!($line =~ /^$str_user$/i)) { push(@templist, $line); } }
4100 open(FILE, ">$groupfile");
4101 flock FILE, 2;
4102 print FILE @templist;
4103 close(FILE);
4104 }
4105
4106 undef @templist;
4107 open(FILE, "$userdb");
4108 @groupmembers = <FILE>;
4109 close(FILE);
4110 foreach $line (@groupmembers) { if (!($line =~ /^$str_user:/i)) { push(@templist, $line); } }
4111 open(FILE, ">$userdb");
4112 flock FILE, 2;
4113 print FILE @templist;
4114 close(FILE);
4115
4116 return;
4117}
ac1cfefa 4118
ed38f89d 4119# -------------------------------------------------------------------
fe1656d2
CS
4120
4121sub writecachemgr
4122{
4123 open(FILE, ">${General::swroot}/proxy/cachemgr.conf");
4124 flock(FILE, 2);
ee4b5bbb
MT
4125 if (&Header::green_used()) {
4126 print FILE "$netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}\n";
4127 }
fe1656d2 4128 print FILE "localhost";
d9f2cfa4 4129 close(FILE);
fe1656d2
CS
4130 return;
4131}
4132
bd027d94 4133# -------------------------------------------------------------------