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