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