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