]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl | |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2010 Michael Tremer & Christian Schmidt # | |
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 | use strict; | |
23 | # enable only the following on debugging purpose | |
24 | #use warnings; | |
25 | #use CGI::Carp 'fatalsToBrowser'; | |
26 | ||
27 | require '/var/ipfire/general-functions.pl'; | |
28 | require "${General::swroot}/lang.pl"; | |
29 | require "${General::swroot}/header.pl"; | |
30 | ||
31 | my %outfwsettings = (); | |
32 | my %checked = (); | |
33 | my %selected= () ; | |
34 | my %netsettings = (); | |
35 | my $errormessage = ""; | |
36 | my $configentry = ""; | |
37 | my @configs = (); | |
38 | my @configline = (); | |
39 | my $p2pentry = ""; | |
40 | my @p2ps = (); | |
41 | my @p2pline = (); | |
42 | ||
43 | my $configfile = "/var/ipfire/outgoing/rules"; | |
44 | my $p2pfile = "/var/ipfire/outgoing/p2protocols"; | |
45 | my $servicefile = "/var/ipfire/outgoing/defaultservices"; | |
46 | ||
47 | my %color = (); | |
48 | my %mainsettings = (); | |
49 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
50 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
51 | ||
52 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); | |
53 | ||
54 | &Header::showhttpheaders(); | |
55 | ||
56 | ### Values that have to be initialized | |
57 | $outfwsettings{'ACTION'} = ''; | |
58 | $outfwsettings{'VALID'} = 'yes'; | |
59 | $outfwsettings{'EDIT'} = 'no'; | |
60 | $outfwsettings{'NAME'} = ''; | |
61 | $outfwsettings{'SNET'} = ''; | |
62 | $outfwsettings{'SIP'} = ''; | |
63 | $outfwsettings{'SPORT'} = ''; | |
64 | $outfwsettings{'SMAC'} = ''; | |
65 | $outfwsettings{'DIP'} = ''; | |
66 | $outfwsettings{'DPORT'} = ''; | |
67 | $outfwsettings{'PROT'} = ''; | |
68 | $outfwsettings{'STATE'} = ''; | |
69 | $outfwsettings{'DISPLAY_DIP'} = ''; | |
70 | $outfwsettings{'DISPLAY_DPORT'} = ''; | |
71 | $outfwsettings{'DISPLAY_SMAC'} = ''; | |
72 | $outfwsettings{'DISPLAY_SIP'} = ''; | |
73 | $outfwsettings{'POLICY'} = 'MODE0'; | |
74 | $outfwsettings{'MODE1LOG'} = 'off'; | |
75 | ||
76 | $outfwsettings{'TIME_FROM'} = '00:00'; | |
77 | $outfwsettings{'TIME_TO'} = '00:00'; | |
78 | ||
79 | &General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings); | |
80 | &Header::getcgihash(\%outfwsettings); | |
81 | ||
82 | $selected{'TIME_FROM'}{$outfwsettings{'TIME_FROM'}} = "selected='selected'"; | |
83 | $selected{'TIME_TO'}{$outfwsettings{'TIME_TO'}} = "selected='selected'"; | |
84 | ||
85 | $checked{'MODE1LOG'}{'off'} = ''; | |
86 | $checked{'MODE1LOG'}{'on'} = ''; | |
87 | $checked{'MODE1LOG'}{$outfwsettings{'MODE1LOG'}} = "checked='checked'"; | |
88 | $checked{'TIME_MON'}{'off'} = ''; | |
89 | $checked{'TIME_MON'}{'on'} = ''; | |
90 | $checked{'TIME_MON'}{$outfwsettings{'TIME_MON'}} = "checked='checked'"; | |
91 | $checked{'TIME_TUE'}{'off'} = ''; | |
92 | $checked{'TIME_TUE'}{'on'} = ''; | |
93 | $checked{'TIME_TUE'}{$outfwsettings{'TIME_TUE'}} = "checked='checked'"; | |
94 | $checked{'TIME_WED'}{'off'} = ''; | |
95 | $checked{'TIME_WED'}{'on'} = ''; | |
96 | $checked{'TIME_WED'}{$outfwsettings{'TIME_WED'}} = "checked='checked'"; | |
97 | $checked{'TIME_THU'}{'off'} = ''; | |
98 | $checked{'TIME_THU'}{'on'} = ''; | |
99 | $checked{'TIME_THU'}{$outfwsettings{'TIME_THU'}} = "checked='checked'"; | |
100 | $checked{'TIME_FRI'}{'off'} = ''; | |
101 | $checked{'TIME_FRI'}{'on'} = ''; | |
102 | $checked{'TIME_FRI'}{$outfwsettings{'TIME_FRI'}} = "checked='checked'"; | |
103 | $checked{'TIME_SAT'}{'off'} = ''; | |
104 | $checked{'TIME_SAT'}{'on'} = ''; | |
105 | $checked{'TIME_SAT'}{$outfwsettings{'TIME_SAT'}} = "checked='checked'"; | |
106 | $checked{'TIME_SUN'}{'off'} = ''; | |
107 | $checked{'TIME_SUN'}{'on'} = ''; | |
108 | $checked{'TIME_SUN'}{$outfwsettings{'TIME_SUN'}} = "checked='checked'"; | |
109 | ||
110 | if ($outfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; } | |
111 | if ($outfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; } | |
112 | if ($outfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; } | |
113 | ||
114 | if ( $outfwsettings{'TIME_MON'} eq "" && | |
115 | $outfwsettings{'TIME_TUE'} eq "" && | |
116 | $outfwsettings{'TIME_WED'} eq "" && | |
117 | $outfwsettings{'TIME_THU'} eq "" && | |
118 | $outfwsettings{'TIME_FRI'} eq "" && | |
119 | $outfwsettings{'TIME_SAT'} eq "" && | |
120 | $outfwsettings{'TIME_SUN'} eq "" ) | |
121 | { | |
122 | $outfwsettings{'TIME_MON'} = "on"; | |
123 | $outfwsettings{'TIME_TUE'} = "on"; | |
124 | $outfwsettings{'TIME_WED'} = "on"; | |
125 | $outfwsettings{'TIME_THU'} = "on"; | |
126 | $outfwsettings{'TIME_FRI'} = "on"; | |
127 | $outfwsettings{'TIME_SAT'} = "on"; | |
128 | $outfwsettings{'TIME_SUN'} = "on"; | |
129 | } | |
130 | ||
131 | &Header::openpage('Ausgehende Firewall', 1, ''); | |
132 | &Header::openbigbox('100%', 'left', '', $errormessage); | |
133 | ||
134 | ############################################################################################################################ | |
135 | ############################################################################################################################ | |
136 | ||
137 | if ($outfwsettings{'ACTION'} eq $Lang::tr{'reset'}) | |
138 | { | |
139 | $outfwsettings{'POLICY'}='MODE0'; | |
140 | unlink $configfile; | |
141 | system("/usr/bin/touch $configfile"); | |
142 | my $MODE = $outfwsettings{'POLICY'}; | |
143 | %outfwsettings = (); | |
144 | $outfwsettings{'POLICY'} = "$MODE"; | |
145 | &General::writehash("${General::swroot}/outgoing/settings", \%outfwsettings); | |
146 | } | |
147 | if ($outfwsettings{'ACTION'} eq $Lang::tr{'save'}) | |
148 | { | |
149 | my $MODE = $outfwsettings{'POLICY'}; | |
150 | my $MODE1LOG = $outfwsettings{'MODE1LOG'}; | |
151 | %outfwsettings = (); | |
152 | $outfwsettings{'POLICY'} = "$MODE"; | |
153 | $outfwsettings{'MODE1LOG'} = "$MODE1LOG"; | |
154 | &General::writehash("${General::swroot}/outgoing/settings", \%outfwsettings); | |
155 | system("/usr/local/bin/outgoingfwctrl"); | |
156 | } | |
157 | if ($outfwsettings{'ACTION'} eq 'enable') | |
158 | { | |
159 | open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile"; | |
160 | @p2ps = <FILE>; | |
161 | close FILE; | |
162 | open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile"; | |
163 | foreach $p2pentry (sort @p2ps) | |
164 | { | |
165 | @p2pline = split( /\;/, $p2pentry ); | |
166 | if ($p2pline[1] eq $outfwsettings{'P2PROT'}) { | |
167 | print FILE "$p2pline[0];$p2pline[1];on;\n"; | |
168 | } else { | |
169 | print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n"; | |
170 | } | |
171 | } | |
172 | close FILE; | |
173 | system("/usr/local/bin/outgoingfwctrl"); | |
174 | } | |
175 | if ($outfwsettings{'ACTION'} eq 'disable') | |
176 | { | |
177 | open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile"; | |
178 | @p2ps = <FILE>; | |
179 | close FILE; | |
180 | open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile"; | |
181 | foreach $p2pentry (sort @p2ps) | |
182 | { | |
183 | @p2pline = split( /\;/, $p2pentry ); | |
184 | if ($p2pline[1] eq $outfwsettings{'P2PROT'}) { | |
185 | print FILE "$p2pline[0];$p2pline[1];off;\n"; | |
186 | } else { | |
187 | print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n"; | |
188 | } | |
189 | } | |
190 | close FILE; | |
191 | system("/usr/local/bin/outgoingfwctrl"); | |
192 | } | |
193 | if ($outfwsettings{'ACTION'} eq $Lang::tr{'edit'}) | |
194 | { | |
195 | open( FILE, "< $configfile" ) or die "Unable to read $configfile"; | |
196 | @configs = <FILE>; | |
197 | close FILE; | |
198 | open( FILE, "> $configfile" ) or die "Unable to write $configfile"; | |
199 | foreach $configentry (sort @configs) | |
200 | { | |
201 | @configline = split( /\;/, $configentry ); | |
202 | unless (($configline[0] eq $outfwsettings{'STATE'}) && | |
203 | ($configline[1] eq $outfwsettings{'ENABLED'}) && | |
204 | ($configline[2] eq $outfwsettings{'SNET'}) && | |
205 | ($configline[3] eq $outfwsettings{'PROT'}) && | |
206 | ($configline[4] eq $outfwsettings{'NAME'}) && | |
207 | ($configline[5] eq $outfwsettings{'SIP'}) && | |
208 | ($configline[6] eq $outfwsettings{'SMAC'}) && | |
209 | ($configline[7] eq $outfwsettings{'DIP'}) && | |
210 | ($configline[9] eq $outfwsettings{'LOG'}) && | |
211 | ($configline[8] eq $outfwsettings{'DPORT'}) && | |
212 | ($configline[10] eq $outfwsettings{'TIME_MON'}) && | |
213 | ($configline[11] eq $outfwsettings{'TIME_TUE'}) && | |
214 | ($configline[12] eq $outfwsettings{'TIME_WED'}) && | |
215 | ($configline[13] eq $outfwsettings{'TIME_THU'}) && | |
216 | ($configline[14] eq $outfwsettings{'TIME_FRI'}) && | |
217 | ($configline[15] eq $outfwsettings{'TIME_SAT'}) && | |
218 | ($configline[16] eq $outfwsettings{'TIME_SUN'}) && | |
219 | ($configline[17] eq $outfwsettings{'TIME_FROM'}) && | |
220 | ($configline[18] eq $outfwsettings{'TIME_TO'})) | |
221 | { | |
222 | print FILE $configentry; | |
223 | } | |
224 | } | |
225 | close FILE; | |
226 | $selected{'SNET'}{"$outfwsettings{'SNET'}"} = 'selected'; | |
227 | $selected{'PROT'}{"$outfwsettings{'PROT'}"} = 'selected'; | |
228 | $selected{'LOG'}{"$outfwsettings{'LOG'}"} = 'selected'; | |
229 | &addrule(); | |
230 | &Header::closebigbox(); | |
231 | &Header::closepage(); | |
232 | exit | |
233 | system("/usr/local/bin/outgoingfwctrl"); | |
234 | } | |
235 | if ($outfwsettings{'ACTION'} eq $Lang::tr{'delete'}) | |
236 | { | |
237 | open( FILE, "< $configfile" ) or die "Unable to read $configfile"; | |
238 | @configs = <FILE>; | |
239 | close FILE; | |
240 | open( FILE, "> $configfile" ) or die "Unable to write $configfile"; | |
241 | foreach $configentry (sort @configs) | |
242 | { | |
243 | @configline = split( /\;/, $configentry ); | |
244 | unless (($configline[0] eq $outfwsettings{'STATE'}) && | |
245 | ($configline[1] eq $outfwsettings{'ENABLED'}) && | |
246 | ($configline[2] eq $outfwsettings{'SNET'}) && | |
247 | ($configline[3] eq $outfwsettings{'PROT'}) && | |
248 | ($configline[4] eq $outfwsettings{'NAME'}) && | |
249 | ($configline[5] eq $outfwsettings{'SIP'}) && | |
250 | ($configline[6] eq $outfwsettings{'SMAC'}) && | |
251 | ($configline[7] eq $outfwsettings{'DIP'}) && | |
252 | ($configline[9] eq $outfwsettings{'LOG'}) && | |
253 | ($configline[8] eq $outfwsettings{'DPORT'}) && | |
254 | ($configline[10] eq $outfwsettings{'TIME_MON'}) && | |
255 | ($configline[11] eq $outfwsettings{'TIME_TUE'}) && | |
256 | ($configline[12] eq $outfwsettings{'TIME_WED'}) && | |
257 | ($configline[13] eq $outfwsettings{'TIME_THU'}) && | |
258 | ($configline[14] eq $outfwsettings{'TIME_FRI'}) && | |
259 | ($configline[15] eq $outfwsettings{'TIME_SAT'}) && | |
260 | ($configline[16] eq $outfwsettings{'TIME_SUN'}) && | |
261 | ($configline[17] eq $outfwsettings{'TIME_FROM'}) && | |
262 | ($configline[18] eq $outfwsettings{'TIME_TO'})) | |
263 | { | |
264 | print FILE $configentry; | |
265 | } | |
266 | } | |
267 | close FILE; | |
268 | system("/usr/local/bin/outgoingfwctrl"); | |
269 | } | |
270 | if ($outfwsettings{'ACTION'} eq $Lang::tr{'add'}) | |
271 | { | |
272 | if ( $outfwsettings{'VALID'} eq 'yes' ) { | |
273 | open( FILE, ">> $configfile" ) or die "Unable to write $configfile"; | |
274 | print FILE <<END | |
275 | $outfwsettings{'STATE'};$outfwsettings{'ENABLED'};$outfwsettings{'SNET'};$outfwsettings{'PROT'};$outfwsettings{'NAME'};$outfwsettings{'SIP'};$outfwsettings{'SMAC'};$outfwsettings{'DIP'};$outfwsettings{'DPORT'};$outfwsettings{'LOG'};$outfwsettings{'TIME_MON'};$outfwsettings{'TIME_TUE'};$outfwsettings{'TIME_WED'};$outfwsettings{'TIME_THU'};$outfwsettings{'TIME_FRI'};$outfwsettings{'TIME_SAT'};$outfwsettings{'TIME_SUN'};$outfwsettings{'TIME_FROM'};$outfwsettings{'TIME_TO'}; | |
276 | END | |
277 | ; | |
278 | close FILE; | |
279 | system("/usr/local/bin/outgoingfwctrl"); | |
280 | } else { | |
281 | $outfwsettings{'ACTION'} = 'Add rule'; | |
282 | } | |
283 | } | |
284 | if ($outfwsettings{'ACTION'} eq 'Add rule') | |
285 | { | |
286 | &addrule(); | |
287 | exit | |
288 | } | |
289 | ||
290 | &General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings); | |
291 | ||
292 | if ($errormessage) { | |
293 | &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); | |
294 | print "<class name='base'>$errormessage\n"; | |
295 | print " </class>\n"; | |
296 | &Header::closebox(); | |
297 | } | |
298 | ||
299 | ############################################################################################################################ | |
300 | ############################################################################################################################ | |
301 | ||
302 | if ($outfwsettings{'POLICY'} ne 'MODE0'){ | |
303 | &Header::openbox('100%', 'center', 'Rules'); | |
304 | print <<END | |
305 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
306 | <input type='submit' name='ACTION' value='Add rule' /> | |
307 | </form> | |
308 | END | |
309 | ; | |
310 | open( FILE, "< $configfile" ) or die "Unable to read $configfile"; | |
311 | @configs = <FILE>; | |
312 | close FILE; | |
313 | if (@configs) { | |
314 | print <<END | |
315 | <hr /> | |
316 | <table border='0' width='100%' cellspacing='0'> | |
317 | <tr bgcolor='$color{'color22'}'> | |
318 | <td width='14%' align='center'><b>$Lang::tr{'protocol'}</b></td> | |
319 | <td width='14%' align='center'><b>$Lang::tr{'network'}</b></td> | |
320 | <td width='14%' align='center'><b>$Lang::tr{'destination'}</b></td> | |
321 | <td width='14%' align='center'><b>$Lang::tr{'description'}</b></td> | |
322 | <td width='14%' align='center'><b>$Lang::tr{'policy'}</b></td> | |
323 | <td width='16%' align='center'><b>$Lang::tr{'logging'}</b></td> | |
324 | <td width='14%' align='center'><b>$Lang::tr{'action'}</b></td> | |
325 | END | |
326 | ; | |
327 | foreach $configentry (sort @configs) | |
328 | { | |
329 | @configline = split( /\;/, $configentry ); | |
330 | $outfwsettings{'STATE'} = $configline[0]; | |
331 | $outfwsettings{'ENABLED'} = $configline[1]; | |
332 | $outfwsettings{'SNET'} = $configline[2]; | |
333 | $outfwsettings{'PROT'} = $configline[3]; | |
334 | $outfwsettings{'NAME'} = $configline[4]; | |
335 | $outfwsettings{'SIP'} = $configline[5]; | |
336 | $outfwsettings{'SMAC'} = $configline[6]; | |
337 | $outfwsettings{'DIP'} = $configline[7]; | |
338 | $outfwsettings{'DPORT'} = $configline[8]; | |
339 | $outfwsettings{'LOG'} = $configline[9]; | |
340 | $outfwsettings{'TIME_MON'} = $configline[10]; | |
341 | $outfwsettings{'TIME_TUE'} = $configline[11]; | |
342 | $outfwsettings{'TIME_WED'} = $configline[12]; | |
343 | $outfwsettings{'TIME_THU'} = $configline[13]; | |
344 | $outfwsettings{'TIME_FRI'} = $configline[14]; | |
345 | $outfwsettings{'TIME_SAT'} = $configline[15]; | |
346 | $outfwsettings{'TIME_SUN'} = $configline[16]; | |
347 | $outfwsettings{'TIME_FROM'} = $configline[17]; | |
348 | $outfwsettings{'TIME_TO'} = $configline[18]; | |
349 | ||
350 | if ($outfwsettings{'DIP'} eq ''){ $outfwsettings{'DISPLAY_DIP'} = 'ALL'; } else { $outfwsettings{'DISPLAY_DIP'} = $outfwsettings{'DIP'}; } | |
351 | if ($outfwsettings{'DPORT'} eq ''){ $outfwsettings{'DISPLAY_DPORT'} = 'ALL'; } else { $outfwsettings{'DISPLAY_DPORT'} = $outfwsettings{'DPORT'}; } | |
352 | if ($outfwsettings{'STATE'} eq 'DENY'){ $outfwsettings{'DISPLAY_STATE'} = "<img src='/images/stock_stop.png' alt='DENY' />"; } | |
353 | if ($outfwsettings{'STATE'} eq 'ALLOW'){ $outfwsettings{'DISPLAY_STATE'} = "<img src='/images/stock_ok.png' alt='ALLOW' />"; } | |
354 | if ((($outfwsettings{'POLICY'} eq 'MODE1') && ($outfwsettings{'STATE'} eq 'ALLOW')) || (($outfwsettings{'POLICY'} eq 'MODE2') && ($outfwsettings{'STATE'} eq 'DENY'))){ | |
355 | print <<END | |
356 | <tr bgcolor='$color{'color20'}'> | |
357 | <td align='center'>$outfwsettings{'PROT'} | |
358 | <td align='center'>$outfwsettings{'SNET'} | |
359 | <td align='center'>$outfwsettings{'DISPLAY_DIP'}:$outfwsettings{'DISPLAY_DPORT'} | |
360 | <td align='center'>$outfwsettings{'NAME'} | |
361 | <td align='center'>$outfwsettings{'DISPLAY_STATE'} | |
362 | <td align='center'>$outfwsettings{'LOG'} | |
363 | <td align='center'> | |
364 | <table border='0' cellpadding='0' cellspacing='0'><tr> | |
365 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
366 | <input type='hidden' name='PROT' value='$outfwsettings{'PROT'}' /> | |
367 | <input type='hidden' name='STATE' value='$outfwsettings{'STATE'}' /> | |
368 | <input type='hidden' name='SNET' value='$outfwsettings{'SNET'}' /> | |
369 | <input type='hidden' name='DPORT' value='$outfwsettings{'DPORT'}' /> | |
370 | <input type='hidden' name='DIP' value='$outfwsettings{'DIP'}' /> | |
371 | <input type='hidden' name='SIP' value='$outfwsettings{'SIP'}' /> | |
372 | <input type='hidden' name='NAME' value='$outfwsettings{'NAME'}' /> | |
373 | <input type='hidden' name='SMAC' value='$outfwsettings{'SMAC'}' /> | |
374 | <input type='hidden' name='ENABLED' value='$outfwsettings{'ENABLED'}' /> | |
375 | <input type='hidden' name='LOG' value='$outfwsettings{'LOG'}' /> | |
376 | <input type='hidden' name='TIME_MON' value='$outfwsettings{'TIME_MON'}' /> | |
377 | <input type='hidden' name='TIME_TUE' value='$outfwsettings{'TIME_TUE'}' /> | |
378 | <input type='hidden' name='TIME_WED' value='$outfwsettings{'TIME_WED'}' /> | |
379 | <input type='hidden' name='TIME_THU' value='$outfwsettings{'TIME_THU'}' /> | |
380 | <input type='hidden' name='TIME_FRI' value='$outfwsettings{'TIME_FRI'}' /> | |
381 | <input type='hidden' name='TIME_SAT' value='$outfwsettings{'TIME_SAT'}' /> | |
382 | <input type='hidden' name='TIME_SUN' value='$outfwsettings{'TIME_SUN'}' /> | |
383 | <input type='hidden' name='TIME_FROM' value='$outfwsettings{'TIME_FROM'}' /> | |
384 | <input type='hidden' name='TIME_TO' value='$outfwsettings{'TIME_TO'}' /> | |
385 | <input type='hidden' name='ACTION' value=$Lang::tr{'edit'} /> | |
386 | <input type='image' src='/images/edit.gif' width="20" height="20" alt=$Lang::tr{'edit'} /> | |
387 | </form> | |
388 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
389 | <input type='hidden' name='PROT' value='$outfwsettings{'PROT'}' /> | |
390 | <input type='hidden' name='STATE' value='$outfwsettings{'STATE'}' /> | |
391 | <input type='hidden' name='SNET' value='$outfwsettings{'SNET'}' /> | |
392 | <input type='hidden' name='DPORT' value='$outfwsettings{'DPORT'}' /> | |
393 | <input type='hidden' name='DIP' value='$outfwsettings{'DIP'}' /> | |
394 | <input type='hidden' name='SIP' value='$outfwsettings{'SIP'}' /> | |
395 | <input type='hidden' name='NAME' value='$outfwsettings{'NAME'}' /> | |
396 | <input type='hidden' name='SMAC' value='$outfwsettings{'SMAC'}' /> | |
397 | <input type='hidden' name='ENABLED' value='$outfwsettings{'ENABLED'}' /> | |
398 | <input type='hidden' name='LOG' value='$outfwsettings{'LOG'}' /> | |
399 | <input type='hidden' name='TIME_MON' value='$outfwsettings{'TIME_MON'}' /> | |
400 | <input type='hidden' name='TIME_TUE' value='$outfwsettings{'TIME_TUE'}' /> | |
401 | <input type='hidden' name='TIME_WED' value='$outfwsettings{'TIME_WED'}' /> | |
402 | <input type='hidden' name='TIME_THU' value='$outfwsettings{'TIME_THU'}' /> | |
403 | <input type='hidden' name='TIME_FRI' value='$outfwsettings{'TIME_FRI'}' /> | |
404 | <input type='hidden' name='TIME_SAT' value='$outfwsettings{'TIME_SAT'}' /> | |
405 | <input type='hidden' name='TIME_SUN' value='$outfwsettings{'TIME_SUN'}' /> | |
406 | <input type='hidden' name='TIME_FROM' value='$outfwsettings{'TIME_FROM'}' /> | |
407 | <input type='hidden' name='TIME_TO' value='$outfwsettings{'TIME_TO'}' /> | |
408 | <input type='hidden' name='ACTION' value=$Lang::tr{'delete'} /> | |
409 | <input type='image' src='/images/delete.gif' width="20" height="20" alt=$Lang::tr{'delete'} /> | |
410 | </form></table> | |
411 | END | |
412 | ; | |
413 | if (($outfwsettings{'SIP'}) || ($outfwsettings{'SMAC'})) { | |
414 | unless ($outfwsettings{'SIP'}) { $outfwsettings{'DISPLAY_SIP'} = 'ALL'; } else { $outfwsettings{'DISPLAY_SIP'} = $outfwsettings{'SIP'}; } | |
415 | unless ($outfwsettings{'SMAC'}) { $outfwsettings{'DISPLAY_SMAC'} = 'ALL'; } else { $outfwsettings{'DISPLAY_SMAC'} = $outfwsettings{'SMAC'}; } | |
416 | print <<END | |
417 | <tr><td width='14%' align='right'>$Lang::tr{'source ip'}: | |
418 | <td width='14%' align='left'>$outfwsettings{'DISPLAY_SIP'} | |
419 | <td width='44%' colspan='2' align='center'> | |
420 | END | |
421 | ; | |
422 | } | |
423 | print <<END | |
424 | <tr><td width='14%' align='right'>$Lang::tr{'time'} - </td> | |
425 | <td width='14%' align='left'> | |
426 | END | |
427 | ; | |
428 | if ($outfwsettings{'TIME_MON'} eq 'on') { print "<font color='$Header::colourgreen'>";} | |
429 | else { print "<font color='$Header::colourred'>";} | |
430 | print "$Lang::tr{'advproxy monday'}</font>,"; | |
431 | if ($outfwsettings{'TIME_TUE'} eq 'on') { print "<font color='$Header::colourgreen'>";} | |
432 | else { print "<font color='$Header::colourred'>";} | |
433 | print "$Lang::tr{'advproxy tuesday'}</font>,"; | |
434 | if ($outfwsettings{'TIME_WED'} eq 'on') { print "<font color='$Header::colourgreen'>";} | |
435 | else { print "<font color='$Header::colourred'>";} | |
436 | print "$Lang::tr{'advproxy wednesday'}</font>,"; | |
437 | if ($outfwsettings{'TIME_THU'} eq 'on') { print "<font color='$Header::colourgreen'>";} | |
438 | else { print "<font color='$Header::colourred'>";} | |
439 | print "$Lang::tr{'advproxy thursday'}</font>,"; | |
440 | if ($outfwsettings{'TIME_FRI'} eq 'on') { print "<font color='$Header::colourgreen'>";} | |
441 | else { print "<font color='$Header::colourred'>";} | |
442 | print "$Lang::tr{'advproxy friday'}</font>,"; | |
443 | if ($outfwsettings{'TIME_SAT'} eq 'on') { print "<font color='$Header::colourgreen'>";} | |
444 | else { print "<font color='$Header::colourred'>";} | |
445 | print "$Lang::tr{'advproxy saturday'}</font>,"; | |
446 | if ($outfwsettings{'TIME_SUN'} eq 'on') { print "<font color='$Header::colourgreen'>";} | |
447 | else { print "<font color='$Header::colourred'>";} | |
448 | print "$Lang::tr{'advproxy sunday'}</font>"; | |
449 | print <<END | |
450 | </td> | |
451 | <td width='22%' align='center'>$Lang::tr{'advproxy from'} $outfwsettings{'TIME_FROM'}</td> | |
452 | <td width='22%' align='center'>$Lang::tr{'advproxy to'} $outfwsettings{'TIME_TO'}</td> | |
453 | </form> | |
454 | END | |
455 | ; | |
456 | } | |
457 | } | |
458 | if ($outfwsettings{'POLICY'} eq 'MODE1'){ | |
459 | print <<END | |
460 | <tr bgcolor='$color{'color20'}'><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
461 | <td align='center'>all | |
462 | <td align='center'>all | |
463 | <td align='center'>ALL | |
464 | <td align='center'>drop | |
465 | <td align='center'><img src='/images/stock_stop.png' alt='DENY' /> | |
466 | <td align='center'>on <input type='radio' name='MODE1LOG' value='on' $checked{'MODE1LOG'}{'on'} /><input type='radio' name='MODE1LOG' value='off' $checked{'MODE1LOG'}{'off'} /> off | |
467 | <td align='center'><input type='hidden' name='ACTION' value=$Lang::tr{'save'} /><input type='image' src='/images/media-floppy.png' width="18" height="18" alt=$Lang::tr{'save'} /></form></tr> | |
468 | <table border='0' cellpadding='0' cellspacing='0'><tr> | |
469 | <td> | |
470 | <td></table> | |
471 | END | |
472 | ; | |
473 | } | |
474 | print <<END | |
475 | </table> | |
476 | END | |
477 | ; | |
478 | ||
479 | } | |
480 | &Header::closebox(); | |
481 | } | |
482 | ||
483 | if ($outfwsettings{'POLICY'} ne 'MODE0'){ | |
484 | open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile"; | |
485 | @p2ps = <FILE>; | |
486 | close FILE; | |
487 | &Header::openbox('100%', 'center', 'P2P-Block'); | |
488 | print <<END | |
489 | <table width='40%'> | |
490 | <tr bgcolor='$color{'color22'}'><td width='66%' align=center><b>$Lang::tr{'protocol'}</b> | |
491 | <td width='33%' align=center><b>$Lang::tr{'status'}</b> | |
492 | END | |
493 | ; | |
494 | my $id = 1; | |
495 | foreach $p2pentry (sort @p2ps) | |
496 | { | |
497 | @p2pline = split( /\;/, $p2pentry ); | |
498 | print <<END | |
499 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
500 | END | |
501 | ; | |
502 | print "\t\t\t<tr bgcolor='$color{'color20'}'>\n"; | |
503 | print <<END | |
504 | <td width='66%' align='center'>$p2pline[0]: | |
505 | <td width='33%' align='center'><input type='hidden' name='P2PROT' value='$p2pline[1]' /> | |
506 | END | |
507 | ; | |
508 | if ($p2pline[2] eq 'on') { | |
509 | print <<END | |
510 | <input type='hidden' name='ACTION' value='disable' /> | |
511 | <input type='image' name='submit' src='/images/stock_ok.png' alt='' /> | |
512 | END | |
513 | ; | |
514 | } else { | |
515 | print <<END | |
516 | <input type='hidden' name='ACTION' value='enable' /> | |
517 | <input type='image' name='submit' src='/images/stock_stop.png' alt='' /> | |
518 | END | |
519 | ; | |
520 | } | |
521 | print <<END | |
522 | </form> | |
523 | END | |
524 | ; | |
525 | } | |
526 | print <<END | |
527 | </table> | |
528 | <br />$Lang::tr{'outgoingfw p2p description'} | |
529 | END | |
530 | ; | |
531 | &Header::closebox(); | |
532 | } | |
533 | ||
534 | &Header::openbox('100%', 'center', 'Policy'); | |
535 | print <<END | |
536 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
537 | <table width='100%'> | |
538 | <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 0:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoingfw mode0'}</td></tr> | |
539 | <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 1:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoingfw mode1'}</td></tr> | |
540 | <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 2:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoingfw mode2'}</td></tr> | |
541 | <tr><td colspan='3'><hr /></td></tr> | |
542 | <tr><td width='10%' align='left'> <select name='POLICY' style="width: 85px"><option value='MODE0' $selected{'POLICY'}{'MODE0'}>$Lang::tr{'mode'} 0</option><option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'mode'} 1</option><option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'mode'} 2</option></select> | |
543 | <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} /> | |
544 | <td width='45%' align='left'> | |
545 | END | |
546 | ; | |
547 | if ($outfwsettings{'POLICY'} ne 'MODE0') { | |
548 | print <<END | |
549 | $Lang::tr{'outgoingfw reset'}: <input type='submit' name='ACTION' value=$Lang::tr{'reset'} /> | |
550 | END | |
551 | ; | |
552 | } | |
553 | print <<END | |
554 | </table> | |
555 | </form> | |
556 | END | |
557 | ; | |
558 | &Header::closebox(); | |
559 | ||
560 | &Header::closebigbox(); | |
561 | &Header::closepage(); | |
562 | ||
563 | ############################################################################################################################ | |
564 | ############################################################################################################################ | |
565 | ||
566 | sub addrule | |
567 | { | |
568 | &Header::openbox('100%', 'center', 'Rules hinzufuegen'); | |
569 | if ($outfwsettings{'EDIT'} eq 'no') { $selected{'ENABLED'} = 'checked'; } | |
570 | $selected{'TIME_FROM'}{$outfwsettings{'TIME_FROM'}} = "selected='selected'"; | |
571 | $selected{'TIME_TO'}{$outfwsettings{'TIME_TO'}} = "selected='selected'"; | |
572 | print <<END | |
573 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
574 | <table width='80%'> | |
575 | <tr><td width='20%' align='right'>$Lang::tr{'description'}: <img src='/blob.gif' /> | |
576 | <td width='30%' align='left'><input type='text' name='NAME' maxlength='30' value='$outfwsettings{'NAME'}' /> | |
577 | <td width='20%' align='right' colspan='2'>$Lang::tr{'active'}: | |
578 | <td width='30%' align='left' colspan='2'><input type='checkbox' name='ENABLED' $selected{'ENABLED'} /> | |
579 | <tr><td width='20%' align='right'>$Lang::tr{'protocol'}: | |
580 | <td width='30%' align='left'> | |
581 | <select name='PROT'> | |
582 | <option value='all' $selected{'PROT'}{'all'}>All</option> | |
583 | <option value='tcp' $selected{'PROT'}{'tcp'}>TCP</option> | |
584 | <option value='udp' $selected{'PROT'}{'udp'}>UDP</option> | |
585 | <option value='gre' $selected{'PROT'}{'gre'}>GRE</option> | |
586 | <option value='esp' $selected{'PROT'}{'esp'}>ESP</option> | |
587 | <option value='tcp&udp' $selected{'PROT'}{'tcp&udp'}>TCP & UDP</option> | |
588 | </select> | |
589 | <td width='20%' align='right' colspan='2'>$Lang::tr{'policy'}: | |
590 | <td width='30%' align='left' colspan='2'> | |
591 | END | |
592 | ; | |
593 | if ($outfwsettings{'POLICY'} eq 'MODE1'){ | |
594 | print "\t\t\tALLOW<input type='hidden' name='STATE' value='ALLOW' />\n"; | |
595 | } elsif ($outfwsettings{'POLICY'} eq 'MODE2'){ | |
596 | print "\t\t\tDENY<input type='hidden' name='STATE' value='DENY' />\n"; | |
597 | } | |
598 | print <<END | |
599 | <tr><td width='20%' align='right'>$Lang::tr{'source net'}: | |
600 | <td width='30%' align='left'><select name='SNET'> | |
601 | <option value='all' $selected{'SNET'}{'ALL'}>$Lang::tr{'all'}</option> | |
602 | <option value='ip' $selected{'SNET'}{'ip'}>$Lang::tr{'source ip'}</option> | |
603 | <option value='red' $selected{'SNET'}{'red'}>$Lang::tr{'red'} IP</option> | |
604 | <option value='green' $selected{'SNET'}{'green'}>$Lang::tr{'green'}</option> | |
605 | END | |
606 | ; | |
607 | if (&Header::blue_used()){ | |
608 | print "\t\t\t<option value='blue' $selected{'SNET'}{'blue'}>$Lang::tr{'wireless'}</option>\n"; | |
609 | } | |
610 | if (&Header::orange_used()){ | |
611 | print "\t\t\t<option value='orange' $selected{'SNET'}{'orange'}>$Lang::tr{'dmz'}</option>\n"; | |
612 | } | |
613 | print <<END | |
614 | </select> | |
615 | <td width='20%' align='right' colspan='2'>$Lang::tr{'source ip'}: <img src='/blob.gif' /> | |
616 | <td width='30%' align='left' colspan='2'><input type='text' name='SIP' maxlength='15' value='$outfwsettings{'SIP'}' /> | |
617 | <tr><td width='20%' align='right'>$Lang::tr{'logging'}: | |
618 | END | |
619 | ; | |
620 | if ($outfwsettings{'POLICY'} eq 'MODE1'){ | |
621 | print "<td width='30%' align='left'><input type='text' name='LOG' maxlength='10' value='$Lang::tr{'inactive'}' readonly='true' /></td>"; | |
622 | } | |
623 | else{ | |
624 | print "<td width='30%' align='left'><select name='LOG'><option value='$Lang::tr{'active'}' $selected{'LOG'}{$Lang::tr{'active'}}>$Lang::tr{'active'}</option><option value='$Lang::tr{'inactive'}' $selected{'LOG'}{$Lang::tr{'inactive'}}>$Lang::tr{'inactive'}</option></select></td>"; | |
625 | } | |
626 | print <<END | |
627 | <td width='20%' align='right' colspan='2' /> | |
628 | <td width='30%' align='left' colspan='2' /> | |
629 | <tr><td width='20%' align='right'>$Lang::tr{'destination ip'}: <img src='/blob.gif' /> | |
630 | <td width='30%' align='left'><input type='text' name='DIP' maxlength='15' value='$outfwsettings{'DIP'}' /> | |
631 | <td width='20%' align='right' colspan='2'>$Lang::tr{'destination port'}: <img src='/blob.gif' /> | |
632 | <td width='30%' align='left' colspan='2'><input type='text' name='DPORT' maxlength='11' value='$outfwsettings{'DPORT'}' /> | |
633 | <tr><td width='20%' align='right'>$Lang::tr{'time'}:</td> | |
634 | <td width='30%' align='left'>$Lang::tr{'advproxy monday'} $Lang::tr{'advproxy tuesday'} $Lang::tr{'advproxy wednesday'} $Lang::tr{'advproxy thursday'} $Lang::tr{'advproxy friday'} $Lang::tr{'advproxy saturday'} $Lang::tr{'advproxy sunday'}</td> | |
635 | <td width='20%' align='right' colspan='2' /> | |
636 | <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td> | |
637 | <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td></tr> | |
638 | <tr><td width='20%' align='right'></td> | |
639 | <td width='30%' align='left'><input type='checkbox' name='TIME_MON' $checked{'TIME_MON'}{'on'} /> | |
640 | <input type='checkbox' name='TIME_TUE' $checked{'TIME_TUE'}{'on'} /> | |
641 | <input type='checkbox' name='TIME_WED' $checked{'TIME_WED'}{'on'} /> | |
642 | <input type='checkbox' name='TIME_THU' $checked{'TIME_THU'}{'on'} /> | |
643 | <input type='checkbox' name='TIME_FRI' $checked{'TIME_FRI'}{'on'} /> | |
644 | <input type='checkbox' name='TIME_SAT' $checked{'TIME_SAT'}{'on'} /> | |
645 | <input type='checkbox' name='TIME_SUN' $checked{'TIME_SUN'}{'on'} /></td> | |
646 | <td width='20%' align='right' colspan='2' /> | |
647 | <td width='15%' align='left'><select name='TIME_FROM'> | |
648 | END | |
649 | ; | |
650 | for (my $i=0;$i<=23;$i++) { | |
651 | $i = sprintf("%02s",$i); | |
652 | for (my $j=0;$j<=45;$j+=15) { | |
653 | $j = sprintf("%02s",$j); | |
654 | my $time = $i.":".$j; | |
655 | print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n"; | |
656 | } | |
657 | } | |
658 | print <<END | |
659 | </select></td> | |
660 | <td width='15%' align='left'><select name='TIME_TO'> | |
661 | END | |
662 | ; | |
663 | for (my $i=0;$i<=23;$i++) { | |
664 | $i = sprintf("%02s",$i); | |
665 | for (my $j=0;$j<=45;$j+=15) { | |
666 | $j = sprintf("%02s",$j); | |
667 | my $time = $i.":".$j; | |
668 | print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n"; | |
669 | } | |
670 | } | |
671 | print <<END | |
672 | </select></td></tr> | |
673 | <tr><td colspan='6'> | |
674 | <tr><td width='40%' align='right' colspan='2'><img src='/blob.gif' />$Lang::tr{'this field may be blank'} | |
675 | <td width='60%' align='left' colspan='4'><input type='submit' name='ACTION' value=$Lang::tr{'add'} /> | |
676 | </table></form> | |
677 | END | |
678 | ; | |
679 | &Header::closebox(); | |
680 | ||
681 | if ($outfwsettings{'POLICY'} eq 'MODE1' || $outfwsettings{'POLICY'} eq 'MODE2') | |
682 | { | |
683 | &Header::openbox('100%', 'center', 'Quick Add'); | |
684 | ||
685 | open( FILE, "< /var/ipfire/outgoing/defaultservices" ) or die "Unable to read default services"; | |
686 | my @defservices = <FILE>; | |
687 | close FILE; | |
688 | ||
689 | print "<table width='100%'><tr bgcolor='$color{'color20'}'><td><b>$Lang::tr{'service'}</b></td><td><b>$Lang::tr{'description'}</b></td><td><b>$Lang::tr{'port'}</b></td><td><b>$Lang::tr{'protocol'}</b></td><td><b>$Lang::tr{'source net'}</b></td><td><b>$Lang::tr{'logging'}</b></td><td><b>$Lang::tr{'action'}</b></td></tr>"; | |
690 | foreach my $serviceline(@defservices) | |
691 | { | |
692 | my @service = split(/,/,$serviceline); | |
693 | print <<END | |
694 | <tr><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
695 | <td>$service[0]<input type='hidden' name='NAME' value='@service[0]' /></td> | |
696 | <td>$service[3]</td> | |
697 | <td><a href='http://isc.sans.org/port_details.php?port=$service[1]' target='top'>$service[1]</a><input type='hidden' name='DPORT' value='@service[1]' /></td> | |
698 | <td>$service[2]<input type='hidden' name='PROT' value='@service[2]' /></td> | |
699 | <td><select name='SNET'><option value='all' $selected{'SNET'}{'ALL'}>$Lang::tr{'all'}</option><option value='green' $selected{'SNET'}{'green'}>$Lang::tr{'green'}</option> | |
700 | END | |
701 | ; | |
702 | if (&Header::blue_used()){ | |
703 | print "<option value='blue' $selected{'SNET'}{'blue'}>$Lang::tr{'wireless'}</option>"; | |
704 | } | |
705 | if (&Header::orange_used()){ | |
706 | print "<option value='orange' $selected{'SNET'}{'orange'}>$Lang::tr{'dmz'}</option>"; | |
707 | } | |
708 | print <<END | |
709 | </select></td> | |
710 | <td><select name='LOG'><option value='$Lang::tr{'active'}'>$Lang::tr{'active'}</option><option value='$Lang::tr{'inactive'}' 'selected'>$Lang::tr{'inactive'}</option></select></td><td> | |
711 | <input type='hidden' name='ACTION' value=$Lang::tr{'add'} /> | |
712 | <input type='image' alt='$Lang::tr{'add'}' src='/images/add.gif' /> | |
713 | <input type='hidden' name='ENABLED' value='on' /> | |
714 | END | |
715 | ; | |
716 | if ($outfwsettings{'POLICY'} eq 'MODE1'){ print "<input type='hidden' name='STATE' value='ALLOW' /></form></td></tr>";} | |
717 | elsif ($outfwsettings{'POLICY'} eq 'MODE2'){print "<input type='hidden' name='STATE' value='DENY' /></form></td></tr>";} | |
718 | } | |
719 | print "</table>"; | |
720 | &Header::closebox(); | |
721 | } | |
722 | } |