]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/outgoingfw.cgi
5 # This code is distributed under the terms of the GPL
11 # enable only the following on debugging purpose
13 use CGI
:: Carp
'fatalsToBrowser' ;
15 require '/var/ipfire/general-functions.pl' ;
16 require "${General::swroot}/lang.pl" ;
17 require "${General::swroot}/header.pl" ;
19 my %outfwsettings = ();
23 my $errormessage = "" ;
31 my $configfile = "/var/ipfire/outgoing/rules" ;
32 my $p2pfile = "/var/ipfire/outgoing/p2protocols" ;
34 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
36 & Header
:: showhttpheaders
();
38 ### Values that have to be initialized
39 $outfwsettings { 'ACTION' } = '' ;
40 $outfwsettings { 'VALID' } = 'yes' ;
41 $outfwsettings { 'EDIT' } = 'no' ;
42 $outfwsettings { 'NAME' } = '' ;
43 $outfwsettings { 'SNET' } = '' ;
44 $outfwsettings { 'SIP' } = '' ;
45 $outfwsettings { 'SPORT' } = '' ;
46 $outfwsettings { 'SMAC' } = '' ;
47 $outfwsettings { 'DIP' } = '' ;
48 $outfwsettings { 'DPORT' } = '' ;
49 $outfwsettings { 'PROT' } = '' ;
50 $outfwsettings { 'STATE' } = '' ;
51 $outfwsettings { 'DISPLAY_DIP' } = '' ;
52 $outfwsettings { 'DISPLAY_DPORT' } = '' ;
53 $outfwsettings { 'DISPLAY_SMAC' } = '' ;
54 $outfwsettings { 'DISPLAY_SIP' } = '' ;
55 $outfwsettings { 'POLICY' } = 'MODE0' ;
57 & General
:: readhash
( "${General::swroot}/outgoing/settings" , \
%outfwsettings );
58 & Header
:: getcgihash
( \
%outfwsettings );
60 if ( $outfwsettings { 'POLICY' } eq 'MODE0' ){ $selected { 'POLICY' }{ 'MODE0' } = 'selected' ; } else { $selected { 'POLICY' }{ 'MODE0' } = '' ; }
61 if ( $outfwsettings { 'POLICY' } eq 'MODE1' ){ $selected { 'POLICY' }{ 'MODE1' } = 'selected' ; } else { $selected { 'POLICY' }{ 'MODE1' } = '' ; }
62 if ( $outfwsettings { 'POLICY' } eq 'MODE2' ){ $selected { 'POLICY' }{ 'MODE2' } = 'selected' ; } else { $selected { 'POLICY' }{ 'MODE2' } = '' ; }
64 & Header
:: openpage
( 'Ausgehende Firewall' , 1 , '' );
67 <script type="text/javascript">
69 function BorderOn (id) { id.className='btnOn' }
70 function BorderOff(id) { id.className='btnOff' }
75 border-right: #D5F0FF 2px Inset;
76 border-top: #D5F0FF 2px Inset;
77 border-left: #D5F0FF 2px Inset;
78 border-bottom: #D5F0FF 2px Inset;
80 text-decoration: None;
81 background-color: #FFFFFF;
84 border-right: #D5F0FF 2px Outset;
85 border-top: #D5F0FF 2px Outset;
86 border-left: #D5F0FF 2px Outset;
87 border-bottom: #D5F0FF 2px Outset;
89 text-decoration: None;
90 background-color: #FFFFFF;
96 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
98 ############################################################################################################################
99 ############################################################################################################################
101 if ( $outfwsettings { 'ACTION' } eq $Lang :: tr
{ 'reset' })
103 $outfwsettings { 'POLICY' }= 'MODE0' ;
105 system ( "/bin/touch $configfile " );
106 & General
:: writehash
( "${General::swroot}/outgoing/settings" , \
%outfwsettings );
108 if ( $outfwsettings { 'ACTION' } eq $Lang :: tr
{ 'save' })
110 & General
:: writehash
( "${General::swroot}/outgoing/settings" , \
%outfwsettings );
112 if ( $outfwsettings { 'ACTION' } eq 'enable' )
114 open ( FILE
, "< $p2pfile " ) or die "Unable to read $p2pfile " ;
117 open ( FILE
, "> $p2pfile " ) or die "Unable to write $p2pfile " ;
118 foreach $p2pentry ( sort @p2ps )
120 @p2pline = split ( /\;/ , $p2pentry );
121 if ( $p2pline [ 1 ] eq $outfwsettings { 'P2PROT' }) {
122 print FILE
" $p2pline [0]; $p2pline [1];on; \n " ;
124 print FILE
" $p2pline [0]; $p2pline [1]; $p2pline [2]; \n " ;
129 if ( $outfwsettings { 'ACTION' } eq 'disable' )
131 open ( FILE
, "< $p2pfile " ) or die "Unable to read $p2pfile " ;
134 open ( FILE
, "> $p2pfile " ) or die "Unable to write $p2pfile " ;
135 foreach $p2pentry ( sort @p2ps )
137 @p2pline = split ( /\;/ , $p2pentry );
138 if ( $p2pline [ 1 ] eq $outfwsettings { 'P2PROT' }) {
139 print FILE
" $p2pline [0]; $p2pline [1];off; \n " ;
141 print FILE
" $p2pline [0]; $p2pline [1]; $p2pline [2]; \n " ;
146 if ( $outfwsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' })
148 open ( FILE
, "< $configfile " ) or die "Unable to read $configfile " ;
151 open ( FILE
, "> $configfile " ) or die "Unable to write $configfile " ;
152 foreach $configentry ( sort @configs )
154 @configline = split ( /\;/ , $configentry );
155 unless (( $configline [ 0 ] eq $outfwsettings { 'STATE' }) &&
156 ( $configline [ 1 ] eq $outfwsettings { 'ENABLED' }) &&
157 ( $configline [ 2 ] eq $outfwsettings { 'SNET' }) &&
158 ( $configline [ 3 ] eq $outfwsettings { 'PROT' }) &&
159 ( $configline [ 4 ] eq $outfwsettings { 'NAME' }) &&
160 ( $configline [ 5 ] eq $outfwsettings { 'SIP' }) &&
161 ( $configline [ 6 ] eq $outfwsettings { 'SMAC' }) &&
162 ( $configline [ 7 ] eq $outfwsettings { 'DIP' }) &&
163 ( $configline [ 8 ] eq $outfwsettings { 'DPORT' }))
165 print FILE
$configentry ;
170 & Header
:: closebigbox
();
171 & Header
:: closepage
();
174 if ( $outfwsettings { 'ACTION' } eq $Lang :: tr
{ 'delete' })
176 open ( FILE
, "< $configfile " ) or die "Unable to read $configfile " ;
179 open ( FILE
, "> $configfile " ) or die "Unable to write $configfile " ;
180 foreach $configentry ( sort @configs )
182 @configline = split ( /\;/ , $configentry );
183 unless (( $configline [ 0 ] eq $outfwsettings { 'STATE' }) &&
184 ( $configline [ 1 ] eq $outfwsettings { 'ENABLED' }) &&
185 ( $configline [ 2 ] eq $outfwsettings { 'SNET' }) &&
186 ( $configline [ 3 ] eq $outfwsettings { 'PROT' }) &&
187 ( $configline [ 4 ] eq $outfwsettings { 'NAME' }) &&
188 ( $configline [ 5 ] eq $outfwsettings { 'SIP' }) &&
189 ( $configline [ 6 ] eq $outfwsettings { 'SMAC' }) &&
190 ( $configline [ 7 ] eq $outfwsettings { 'DIP' }) &&
191 ( $configline [ 8 ] eq $outfwsettings { 'DPORT' }))
193 print FILE
$configentry ;
198 if ( $outfwsettings { 'ACTION' } eq $Lang :: tr
{ 'add' })
200 if ( $outfwsettings { 'VALID' } eq 'yes' ) {
201 open ( FILE
, ">> $configfile " ) or die "Unable to write $configfile " ;
203 $outfwsettings {'STATE'}; $outfwsettings {'ENABLED'}; $outfwsettings {'SNET'}; $outfwsettings {'PROT'}; $outfwsettings {'NAME'}; $outfwsettings {'SIP'}; $outfwsettings {'SMAC'}; $outfwsettings {'DIP'}; $outfwsettings {'DPORT'};
208 $outfwsettings { 'ACTION' } = 'Regel hinzufuegen' ;
211 if ( $outfwsettings { 'ACTION' } eq 'Regel hinzufuegen' )
217 & General
:: readhash
( "${General::swroot}/outgoing/settings" , \
%outfwsettings );
220 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
221 print "<class name='base'> $errormessage \n " ;
222 print " </class> \n " ;
226 ############################################################################################################################
227 ############################################################################################################################
229 if ( $outfwsettings { 'POLICY' } ne 'MODE0' ){
230 & Header
:: openbox
( '100%' , 'center' , 'Rules' );
232 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
233 <input type='submit' name='ACTION' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)' value='Regel hinzufuegen'>
236 open ( FILE
, "< $configfile " ) or die "Unable to read $configfile " ;
242 <table border='0' width='100%' cellspacing='0'>
243 <tr><td bgcolor='lightgrey' width='14%'>Protokoll
244 <td bgcolor='lightgrey' width='14%'>Netzwerk
245 <td bgcolor='lightgrey' width='14%'>Ziel
246 <td bgcolor='lightgrey' width='14%'>Anmerkung
247 <td bgcolor='lightgrey' width='14%'>Politik
248 <td bgcolor='lightgrey' width='30%'>Aktionen
251 foreach $configentry ( sort @configs )
253 @configline = split ( /\;/ , $configentry );
254 $outfwsettings { 'STATE' } = $configline [ 0 ];
255 $outfwsettings { 'ENABLED' } = $configline [ 1 ];
256 $outfwsettings { 'SNET' } = $configline [ 2 ];
257 $outfwsettings { 'PROT' } = $configline [ 3 ];
258 $outfwsettings { 'NAME' } = $configline [ 4 ];
259 $outfwsettings { 'SIP' } = $configline [ 5 ];
260 $outfwsettings { 'SMAC' } = $configline [ 6 ];
261 $outfwsettings { 'DIP' } = $configline [ 7 ];
262 $outfwsettings { 'DPORT' } = $configline [ 8 ];
263 if ( $outfwsettings { 'DIP' } eq '' ){ $outfwsettings { 'DISPLAY_DIP' } = 'ALL' ; } else { $outfwsettings { 'DISPLAY_DIP' } = $outfwsettings { 'DIP' }; }
264 if ( $outfwsettings { 'DPORT' } eq '' ){ $outfwsettings { 'DISPLAY_DPORT' } = 'ALL' ; } else { $outfwsettings { 'DISPLAY_DPORT' } = $outfwsettings { 'DPORT' }; }
265 if ( $outfwsettings { 'STATE' } eq 'DENY' ){ $outfwsettings { 'DISPLAY_STATE' } = "<img src='/images/stock_stop.png' alt='DENY'>" ; }
266 if ( $outfwsettings { 'STATE' } eq 'ALLOW' ){ $outfwsettings { 'DISPLAY_STATE' } = "<img src='/images/stock_ok.png' alt='ALLOW'>" ; }
267 if ((( $outfwsettings { 'POLICY' } eq 'MODE1' ) && ( $outfwsettings { 'STATE' } eq 'ALLOW' )) || (( $outfwsettings { 'POLICY' } eq 'MODE2' ) && ( $outfwsettings { 'STATE' } eq 'DENY' ))){
269 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
270 <input type='hidden' name='PROT' value= $outfwsettings {'PROT'}>
271 <input type='hidden' name='STATE' value= $outfwsettings {'STATE'}>
272 <input type='hidden' name='SNET' value= $outfwsettings {'SNET'}>
273 <input type='hidden' name='DPORT' value= $outfwsettings {'DPORT'}>
274 <input type='hidden' name='DIP' value= $outfwsettings {'DIP'}>
275 <input type='hidden' name='SIP' value= $outfwsettings {'SIP'}>
276 <input type='hidden' name='NAME' value= $outfwsettings {'NAME'}>
277 <input type='hidden' name='SMAC' value= $outfwsettings {'SMAC'}>
278 <input type='hidden' name='ENABLED' value= $outfwsettings {'ENABLED'}>
279 <tr><td align='center' bgcolor='#EAEAEA'> $outfwsettings {'PROT'}
280 <td align='center' bgcolor='#EAEAEA'> $outfwsettings {'SNET'}
281 <td align='center' bgcolor='#EAEAEA'> $outfwsettings {'DISPLAY_DIP'}: $outfwsettings {'DISPLAY_DPORT'}
282 <td align='center' bgcolor='#EAEAEA'> $outfwsettings {'NAME'}
283 <td align='center' bgcolor='#EAEAEA'> $outfwsettings {'DISPLAY_STATE'}
284 <td align='right' bgcolor='#EAEAEA'>
285 <button type='submit' name='ACTION' value= $Lang ::tr{'edit'} class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt= $Lang ::tr{'edit'}></button>
286 <button type='submit' name='ACTION' value= $Lang ::tr{'delete'} class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt= $Lang ::tr{'delete'}></button>
289 if (( $outfwsettings { 'SIP' }) || ( $outfwsettings { 'SMAC' })) {
290 unless ( $outfwsettings { 'SIP' }) { $outfwsettings { 'DISPLAY_SIP' } = '---' ; } else { $outfwsettings { 'DISPLAY_SIP' } = $outfwsettings { 'SIP' }; }
291 unless ( $outfwsettings { 'SMAC' }) { $outfwsettings { 'DISPLAY_SMAC' } = '---' ; } else { $outfwsettings { 'DISPLAY_SMAC' } = $outfwsettings { 'SMAC' }; }
293 <tr><td width='14%' align='right' bgcolor='#FAFAFA'>Quell-IP-Adresse:
294 <td width='14%' align='left' bgcolor='#FAFAFA'> $outfwsettings {'DISPLAY_SIP'}
295 <td width='14%' align='right' bgcolor='#FAFAFA'>Quell-MAC-Adresse:
296 <td width='14%' align='left' bgcolor='#FAFAFA'> $outfwsettings {'DISPLAY_SMAC'}
297 <td width='44%' colspan='2' align='center' bgcolor='#FAFAFA'>
320 if ( $outfwsettings { 'POLICY' } eq 'MODE2' ){
321 open ( FILE
, "< $p2pfile " ) or die "Unable to read $p2pfile " ;
324 & Header
:: openbox
( '100%' , 'center' , 'P2P-Block' );
327 <tr><td bgcolor='lightgrey' width='66%'>Protokoll
328 <td bgcolor='lightgrey' width='33%'>Status
331 foreach $p2pentry ( sort @p2ps )
333 @p2pline = split ( /\;/ , $p2pentry );
335 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
336 <tr><td width='66%' align='center'> $p2pline [0]:
337 <td width='33%' align='center'><input type='hidden' name='P2PROT' value= $p2pline [1]>
340 if ( $p2pline [ 2 ] eq 'on' ) {
342 <input type='hidden' name='ACTION' value='disable'>
343 <input type='image' name='submit' src='/images/stock_ok.png' alt=''>
348 <input type='hidden' name='ACTION' value='enable'>
349 <input type='image' name='submit' src='/images/stock_stop.png' alt=''>
359 <tr><td colspan='2' align='center'>Klicken Sie auf die Symbole um das entsprechende P2P-Netz zu (de-)aktivieren.
366 & Header
:: openbox
( '100%' , 'center' , 'Policy' );
368 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
370 <tr><td width='10%' align='right'><b>Modus 0:</b><td width='90%' align='left' colspan='2'>In diesem Modus ist es allen Rechnern im Netzwerk uneingeschraenkt moeglich Verbindungen ins Internet aufzubauen.
371 <tr><td width='10%' align='right'><b>Modus 1:</b><td width='90%' align='left' colspan='2'>In diesem Modus werden nur Verbindungen nach den oben definierten Regeln zugelassen.
372 <tr><td width='10%' align='right'><b>Modus 2:</b><td width='90%' align='left' colspan='2'>In diesem Modus werden saemtliche Verbindungen erlaubt, bis auf die oben definierten Block-Regeln.<br>Hier ist eine Besonderheit der P2P-Filter.
373 <tr><td colspan='3'><hr>
374 <tr><td width='10%' align='right'> <select name='POLICY'><option value='MODE0' $selected {'POLICY'}{'MODE0'}>Modus 0</option><option value='MODE1' $selected {'POLICY'}{'MODE1'}>Modus 1</option><option value='MODE2' $selected {'POLICY'}{'MODE2'}>Modus 2</option></select>
375 <td width='45%' align='left'><input type='submit' name='ACTION' value= $Lang ::tr{'save'}>
376 <td width='45%' align='right'>
379 if ( $outfwsettings { 'POLICY' } ne 'MODE0' ) {
381 Alle Regeln loeschen: <input type='submit' name='ACTION' value= $Lang ::tr{'reset'}>
392 & Header
:: closebigbox
();
393 & Header
:: closepage
();
395 ############################################################################################################################
396 ############################################################################################################################
400 & Header
:: openbox
( '100%' , 'center' , 'Rules hinzufuegen' );
401 if ( $outfwsettings { 'EDIT' } eq 'no' ) { $selected { 'ENABLED' } = 'checked' ; }
403 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
405 <tr><td width='20%' align='right'>Anmerkung: <img src='/blob.gif'>
406 <td width='30%' align='left'><input type='text' name='NAME' maxlength='30' value=' $outfwsettings {'NAME'}'>
407 <td width='20%' align='right'>Aktiviert:
408 <td width='30%' align='left'><input type='checkbox' name='ENABLED' $selected {'ENABLED'}>
409 <tr><td width='20%' align='right'>Protokoll:
410 <td width='30%' align='left'><select name='PROT'><option value='tcp' $selected {'PROT'}{'TCP'}>TCP</option><option value='udp' $selected {'PROT'}{'UDP'}>UDP</option></select>
411 <td width='20%' align='right'>Sicherheitspolitik:
412 <td width='30%' align='left'>
415 if ( $outfwsettings { 'POLICY' } eq 'MODE1' ){
416 print " \t\t\t ALLOW<input type='hidden' name='STATE' value='ALLOW'> \n " ;
417 } elsif ( $outfwsettings { 'POLICY' } eq 'MODE2' ){
418 print " \t\t\t DENY<input type='hidden' name='STATE' value='DENY'> \n " ;
421 <tr><td width='20%' align='right'>Quellnetz:
422 <td width='30%' align='left'><select name='SNET'>
423 <option value='all' $selected {'SNET'}{'ALL'}>alle</option>
424 <option value='green' $selected {'SNET'}{'GREEN'}>Gruen</option>
427 if (& Header
:: blue_used
()){
428 print " \t\t\t <option value='blue' $selected {'SNET'}{'BLUE'}>Blau</option> \n " ;
430 if (& Header
:: orange_used
()){
431 print " \t\t\t <option value='orange' $selected {'SNET'}{'ORANGE'}>Orange</option> \n " ;
435 <td width='20%' align='right'>Quell-IP-Adresse: <img src='/blob.gif'>
436 <td width='30%' align='left'><input type='text' name='SIP' maxlength='15' value=' $outfwsettings {'SIP'}'>
437 <tr><td width='50%' colspan='2'>
438 <td width='20%' align='right'>Quell-MAC-Adresse: <img src='/blob.gif'>
439 <td width='30%' align='left'><input type='text' name='SMAC' maxlength='23' value=' $outfwsettings {'SMAC'}'>
440 <tr><td width='20%' align='right'>Ziel-IP-Adresse: <img src='/blob.gif'>
441 <td width='30%' align='left'><input type='text' name='DIP' maxlength='15' value=' $outfwsettings {'DIP'}'>
442 <td width='20%' align='right'>Ziel-Port: <img src='/blob.gif'>
443 <td width='30%' align='left'><input type='text' name='DPORT' maxlength='5' value=' $outfwsettings {'DPORT'}'>
445 <tr><td width='40%' align='right' colspan='2'><img src='/blob.gif'> $Lang ::tr{'this field may be blank'}
446 <td width='60%' align='left' colspan='2'><input type='submit' name='ACTION' value= $Lang ::tr{'add'}>