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