]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/outgoingfw.cgi
Added all option to outgoingfw.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / outgoingfw.cgi
index 2b529752efabb7042b8ff423585e44332d8d59b9..0730ba2d3d9145f17de42ff457a700153a39dbbe 100644 (file)
@@ -1,16 +1,28 @@
 #!/usr/bin/perl
-#
-# IPFire CGIs
-#
-# This code is distributed under the terms of the GPL
-#
-# (c) The IPFire Team
-#
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
 
 use strict;
 # enable only the following on debugging purpose
-use warnings;
-use CGI::Carp 'fatalsToBrowser';
+#use warnings;
+#use CGI::Carp 'fatalsToBrowser';
 
 require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
@@ -59,10 +71,15 @@ $outfwsettings{'DISPLAY_DPORT'} = '';
 $outfwsettings{'DISPLAY_SMAC'} = '';
 $outfwsettings{'DISPLAY_SIP'} = '';
 $outfwsettings{'POLICY'} = 'MODE0';
+$outfwsettings{'MODE1LOG'} = 'off';
 
 &General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings);
 &Header::getcgihash(\%outfwsettings);
 
+$checked{'MODE1LOG'}{'off'} = '';
+$checked{'MODE1LOG'}{'on'} = '';
+$checked{'MODE1LOG'}{$outfwsettings{'MODE1LOG'}} = "checked='checked'";
+
 if ($outfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
 if ($outfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
 if ($outfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
@@ -86,8 +103,10 @@ if ($outfwsettings{'ACTION'} eq $Lang::tr{'reset'})
 if ($outfwsettings{'ACTION'} eq $Lang::tr{'save'})
 {
        my $MODE = $outfwsettings{'POLICY'};
+       my $MODE1LOG = $outfwsettings{'MODE1LOG'};
        %outfwsettings = ();
        $outfwsettings{'POLICY'} = "$MODE";
+       $outfwsettings{'MODE1LOG'} = "$MODE1LOG";
        &General::writehash("${General::swroot}/outgoing/settings", \%outfwsettings);
        system("/usr/local/bin/outgoingfwctrl");
 }
@@ -234,13 +253,13 @@ END
                <hr />
                <table border='0' width='100%' cellspacing='0'>
                <tr bgcolor='$color{'color22'}'>
-                   <td width='14%' align='center'><b>Protokoll</b>
-                   <td width='14%' align='center'><b>Netzwerk</b>
-                   <td width='14%' align='center'><b>Ziel</b>
-                   <td width='14%' align='center'><b>Anmerkung</b>
-                   <td width='14%' align='center'><b>Politik</b>
-                   <td width='16%' align='center'><b>Logging</b>
-                   <td width='14%' align='center'><b>Aktionen</b>
+                   <td width='14%' align='center'><b>$Lang::tr{'protocol'}</b></td>
+                   <td width='14%' align='center'><b>$Lang::tr{'network'}</b></td>
+                   <td width='14%' align='center'><b>$Lang::tr{'destination'}</b></td>
+                   <td width='14%' align='center'><b>$Lang::tr{'description'}</b></td>
+                   <td width='14%' align='center'><b>$Lang::tr{'policy'}</b></td>
+                   <td width='16%' align='center'><b>$Lang::tr{'logging'}</b></td>
+                   <td width='14%' align='center'><b>$Lang::tr{'action'}</b></td>
 END
 ;
                foreach $configentry (sort @configs)
@@ -305,10 +324,8 @@ END
                                                unless ($outfwsettings{'SIP'}) { $outfwsettings{'DISPLAY_SIP'} = 'ALL'; } else { $outfwsettings{'DISPLAY_SIP'} = $outfwsettings{'SIP'}; }
                                                unless ($outfwsettings{'SMAC'}) { $outfwsettings{'DISPLAY_SMAC'} = 'ALL'; } else { $outfwsettings{'DISPLAY_SMAC'} = $outfwsettings{'SMAC'}; }
                                                print <<END
-                                               <tr><td width='14%' align='right'>Quell-IP-Adresse: 
+                                               <tr><td width='14%' align='right'>$Lang::tr{'source ip'}:
                                                    <td width='14%' align='left'>$outfwsettings{'DISPLAY_SIP'}
-                                                   <td width='14%' align='right'>Quell-MAC-Adresse:
-                                                   <td width='14%' align='left'>$outfwsettings{'DISPLAY_SMAC'}
                                                    <td width='44%' colspan='2' align='center'>
 END
 ;
@@ -319,6 +336,22 @@ END
 ;
                                }
                        }
+if ($outfwsettings{'POLICY'} eq 'MODE1'){
+print <<END
+                                       <tr bgcolor='$color{'color20'}'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+                                           <td align='center'>tcp&udp
+                                           <td align='center'>all
+                                           <td align='center'>ALL
+                                           <td align='center'>drop
+                                           <td align='center'><img src='/images/stock_stop.png' alt='DENY' />
+                                           <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
+                                           <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>
+                                            <table border='0' cellpadding='0' cellspacing='0'><tr>
+                                               <td>
+                                               <td></table>
+END
+;
+}
                print <<END
                </table>
 END
@@ -335,8 +368,8 @@ if ($outfwsettings{'POLICY'} ne 'MODE0'){
        &Header::openbox('100%', 'center', 'P2P-Block');
        print <<END
        <table width='40%'>
-               <tr bgcolor='$color{'color22'}'><td width='66%' align=center><b>Protokoll</b>
-                   <td width='33%' align=center><b>Status</b>
+               <tr bgcolor='$color{'color22'}'><td width='66%' align=center><b>$Lang::tr{'protocol'}</b>
+                   <td width='33%' align=center><b>$Lang::tr{'status'}</b>
 END
 ;
        my $id = 1;
@@ -373,7 +406,7 @@ END
        }
        print <<END
        </table>
-  <br />Klicken Sie auf die Symbole um das entsprechende iptables P2P-Blockmodul zu (de-)aktivieren.
+  <br />$Lang::tr{'outgoingfw p2p description'}
 END
 ;
        &Header::closebox();
@@ -383,18 +416,18 @@ END
 print <<END
        <form method='post' action='$ENV{'SCRIPT_NAME'}'>
        <table width='100%'>
-               <tr><td width='10%' align='left'><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.</td></tr>
-               <tr><td width='10%' align='left'><b>Modus 1:</b><td width='90%' align='left' colspan='2'>In diesem Modus werden nur Verbindungen nach den oben definierten Regeln zugelassen.</td></tr>
-               <tr><td width='10%' align='left'><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.</td></tr>
+               <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>
+               <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>
+               <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>
                <tr><td colspan='3'><hr /></td></tr>
-               <tr><td width='10%' align='left'>       <select name='POLICY' style="width: 85px"><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>
+               <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>
                    <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
                    <td width='45%' align='left'>
 END
 ;
        if ($outfwsettings{'POLICY'} ne 'MODE0') {
                print <<END
-                   Alle Regeln loeschen: <input type='submit' name='ACTION' value=$Lang::tr{'reset'} />
+                   $Lang::tr{'outgoingfw reset'}: <input type='submit' name='ACTION' value=$Lang::tr{'reset'} />
 END
 ;
        }
@@ -418,13 +451,13 @@ sub addrule
        print <<END
        <form method='post' action='$ENV{'SCRIPT_NAME'}'>
        <table width='80%'>
-               <tr><td width='20%' align='right'>Anmerkung: <img src='/blob.gif' />
+               <tr><td width='20%' align='right'>$Lang::tr{'description'}: <img src='/blob.gif' />
                    <td width='30%' align='left'><input type='text' name='NAME' maxlength='30' value='$outfwsettings{'NAME'}' />
-                   <td width='20%' align='right'>Aktiviert:
+                   <td width='20%' align='right'>$Lang::tr{'active'}:
                    <td width='30%' align='left'><input type='checkbox' name='ENABLED' $selected{'ENABLED'} />
-               <tr><td width='20%' align='right'>Protokoll:
-                   <td width='30%' align='left'><select name='PROT'><option value='tcp' $selected{'PROT'}{'tcp'}>TCP</option><option value='tcp&udp' $selected{'PROT'}{'tcp&udp'}>TCP & UDP</option><option value='udp' $selected{'PROT'}{'udp'}>UDP</option></select>
-                   <td width='20%' align='right'>Sicherheitspolitik:
+               <tr><td width='20%' align='right'>$Lang::tr{'protocol'}:
+                   <td width='30%' align='left'><select name='PROT'><option value='tcp' $selected{'PROT'}{'all'}>All</option><option value='tcp' $selected{'PROT'}{'tcp'}>TCP</option><option value='tcp&udp' $selected{'PROT'}{'tcp&udp'}>TCP & UDP</option><option value='udp' $selected{'PROT'}{'udp'}>UDP</option></select>
+                   <td width='20%' align='right'>$Lang::tr{'policy'}:
                    <td width='30%' align='left'>
 END
 ;
@@ -434,10 +467,10 @@ END
                print "\t\t\tDENY<input type='hidden' name='STATE' value='DENY' />\n";
        }
        print <<END
-               <tr><td width='20%' align='right'>Quellnetz:
+               <tr><td width='20%' align='right'>$Lang::tr{'source net'}:
                    <td width='30%' align='left'><select name='SNET'>
-                       <option value='all' $selected{'SNET'}{'ALL'}>alle</option>
-                       <option value='ip' $selected{'SNET'}{'ip'}>Quell-IP/MAC benutzen</option>
+                       <option value='all' $selected{'SNET'}{'ALL'}>$Lang::tr{'all'}</option>
+                       <option value='ip' $selected{'SNET'}{'ip'}>$Lang::tr{'source ip'}</option>
                        <option value='green' $selected{'SNET'}{'green'}>$Lang::tr{'green'}</option>
 END
 ;
@@ -449,15 +482,23 @@ END
        }
        print <<END
                        </select>
-                   <td width='20%' align='right'>Quell-IP-Adresse: <img src='/blob.gif' />
+                   <td width='20%' align='right'>$Lang::tr{'source ip'}: <img src='/blob.gif' />
                    <td width='30%' align='left'><input type='text' name='SIP' maxlength='15' value='$outfwsettings{'SIP'}' />
-               <tr><td width='20%' align='right'>Logging:
-                   <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>
-                   <td width='20%' align='right'>Quell-MAC-Adresse: <img src='/blob.gif' />
-                   <td width='30%' align='left'><input type='text' name='SMAC' maxlength='23' value='$outfwsettings{'SMAC'}' />
-               <tr><td width='20%' align='right'>Ziel-IP-Adresse: <img src='/blob.gif' />
+               <tr><td width='20%' align='right'>$Lang::tr{'logging'}:
+END
+;
+if ($outfwsettings{'POLICY'} eq 'MODE1'){
+        print "<td width='30%' align='left'><input type='text' name='LOG' maxlength='10' value='$Lang::tr{'inactive'}' readonly='true' /></td>";
+}
+else{
+        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>";
+}
+print <<END
+                   <td width='20%' align='right' />
+                   <td width='30%' align='left' />
+               <tr><td width='20%' align='right'>$Lang::tr{'destination ip'}: <img src='/blob.gif' />
                    <td width='30%' align='left'><input type='text' name='DIP' maxlength='15' value='$outfwsettings{'DIP'}' />
-                   <td width='20%' align='right'>Ziel-Port: <img src='/blob.gif' />
+                   <td width='20%' align='right'>$Lang::tr{'destination port'}: <img src='/blob.gif' />
                    <td width='30%' align='left'><input type='text' name='DPORT' maxlength='11' value='$outfwsettings{'DPORT'}' />
                <tr><td colspan='4'>
                <tr><td width='40%' align='right' colspan='2'><img src='/blob.gif' />$Lang::tr{'this field may be blank'}
@@ -475,7 +516,7 @@ if ($outfwsettings{'POLICY'} eq 'MODE1' || $outfwsettings{'POLICY'} eq 'MODE2')
        my @defservices = <FILE>;
        close FILE;
 
-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></td></tr>";
+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>";
 foreach my $serviceline(@defservices)
        {
        my @service = split(/,/,$serviceline);