Hinzugefügt:

* WebGUI für die ausgehende Firewall.


git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@204 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
ms
2006-07-07 15:53:12 +00:00
parent e57bc1fd98
commit d9b7aa3334
5 changed files with 457 additions and 2 deletions

451
html/cgi-bin/outgoingfw.cgi Normal file
View File

@@ -0,0 +1,451 @@
#!/usr/bin/perl
#
# IPFire CGIs
#
# This code is distributed under the terms of the GPL
#
# (c) The IPFire Team
#
use strict;
# enable only the following on debugging purpose
use warnings;
use CGI::Carp 'fatalsToBrowser';
require '/var/ipfire/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %outfwsettings = ();
my %checked = ();
my %selected= () ;
my %netsettings = ();
my $errormessage = "";
my $configentry = "";
my @configs = ();
my @configline = ();
my $p2pentry = "";
my @p2ps = ();
my @p2pline = ();
my $configfile = "/var/ipfire/outgoing/rules";
my $p2pfile = "/var/ipfire/outgoing/p2protocols";
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&Header::showhttpheaders();
### Values that have to be initialized
$outfwsettings{'ACTION'} = '';
$outfwsettings{'VALID'} = 'yes';
$outfwsettings{'EDIT'} = 'no';
$outfwsettings{'NAME'} = '';
$outfwsettings{'SNET'} = '';
$outfwsettings{'SIP'} = '';
$outfwsettings{'SPORT'} = '';
$outfwsettings{'SMAC'} = '';
$outfwsettings{'DIP'} = '';
$outfwsettings{'DPORT'} = '';
$outfwsettings{'PROT'} = '';
$outfwsettings{'STATE'} = '';
$outfwsettings{'DISPLAY_DIP'} = '';
$outfwsettings{'DISPLAY_DPORT'} = '';
$outfwsettings{'DISPLAY_SMAC'} = '';
$outfwsettings{'DISPLAY_SIP'} = '';
&General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings);
&Header::getcgihash(\%outfwsettings);
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'} = ''; }
&Header::openpage('Ausgehende Firewall', 1, '');
print <<END
<script type="text/javascript">
<!--
function BorderOn (id) { id.className='btnOn' }
function BorderOff(id) { id.className='btnOff' }
//-->
</script>
<style type=text/css>
.btnOn {
border-right: #D5F0FF 2px Inset;
border-top: #D5F0FF 2px Inset;
border-left: #D5F0FF 2px Inset;
border-bottom: #D5F0FF 2px Inset;
text-align: Center;
text-decoration: None;
background-color: #FFFFFF;
}
.btnOff {
border-right: #D5F0FF 2px Outset;
border-top: #D5F0FF 2px Outset;
border-left: #D5F0FF 2px Outset;
border-bottom: #D5F0FF 2px Outset;
text-align: Center;
text-decoration: None;
background-color: #FFFFFF;
}
</style>
END
;
&Header::openbigbox('100%', 'left', '', $errormessage);
############################################################################################################################
############################################################################################################################
if ($outfwsettings{'ACTION'} eq $Lang::tr{'reset'})
{
$outfwsettings{'POLICY'}='MODE0';
unlink $configfile;
system("/bin/touch $configfile");
&General::writehash("${General::swroot}/outgoing/settings", \%outfwsettings);
}
if ($outfwsettings{'ACTION'} eq $Lang::tr{'save'})
{
&General::writehash("${General::swroot}/outgoing/settings", \%outfwsettings);
}
if ($outfwsettings{'ACTION'} eq 'enable')
{
open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
@p2ps = <FILE>;
close FILE;
open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile";
foreach $p2pentry (sort @p2ps)
{
@p2pline = split( /\;/, $p2pentry );
if ($p2pline[1] eq $outfwsettings{'P2PROT'}) {
print FILE "$p2pline[0];$p2pline[1];on;\n";
} else {
print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n";
}
}
close FILE;
}
if ($outfwsettings{'ACTION'} eq 'disable')
{
open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
@p2ps = <FILE>;
close FILE;
open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile";
foreach $p2pentry (sort @p2ps)
{
@p2pline = split( /\;/, $p2pentry );
if ($p2pline[1] eq $outfwsettings{'P2PROT'}) {
print FILE "$p2pline[0];$p2pline[1];off;\n";
} else {
print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n";
}
}
close FILE;
}
if ($outfwsettings{'ACTION'} eq $Lang::tr{'edit'})
{
open( FILE, "< $configfile" ) or die "Unable to read $configfile";
@configs = <FILE>;
close FILE;
open( FILE, "> $configfile" ) or die "Unable to write $configfile";
foreach $configentry (sort @configs)
{
@configline = split( /\;/, $configentry );
unless (($configline[0] eq $outfwsettings{'STATE'}) &&
($configline[1] eq $outfwsettings{'ENABLED'}) &&
($configline[2] eq $outfwsettings{'SNET'}) &&
($configline[3] eq $outfwsettings{'PROT'}) &&
($configline[4] eq $outfwsettings{'NAME'}) &&
($configline[5] eq $outfwsettings{'SIP'}) &&
($configline[6] eq $outfwsettings{'SMAC'}) &&
($configline[7] eq $outfwsettings{'DIP'}) &&
($configline[8] eq $outfwsettings{'DPORT'}))
{
print FILE $configentry;
}
}
close FILE;
&addrule();
&Header::closebigbox();
&Header::closepage();
exit
}
if ($outfwsettings{'ACTION'} eq $Lang::tr{'delete'})
{
open( FILE, "< $configfile" ) or die "Unable to read $configfile";
@configs = <FILE>;
close FILE;
open( FILE, "> $configfile" ) or die "Unable to write $configfile";
foreach $configentry (sort @configs)
{
@configline = split( /\;/, $configentry );
unless (($configline[0] eq $outfwsettings{'STATE'}) &&
($configline[1] eq $outfwsettings{'ENABLED'}) &&
($configline[2] eq $outfwsettings{'SNET'}) &&
($configline[3] eq $outfwsettings{'PROT'}) &&
($configline[4] eq $outfwsettings{'NAME'}) &&
($configline[5] eq $outfwsettings{'SIP'}) &&
($configline[6] eq $outfwsettings{'SMAC'}) &&
($configline[7] eq $outfwsettings{'DIP'}) &&
($configline[8] eq $outfwsettings{'DPORT'}))
{
print FILE $configentry;
}
}
close FILE;
}
if ($outfwsettings{'ACTION'} eq $Lang::tr{'add'})
{
if ( $outfwsettings{'VALID'} eq 'yes' ) {
open( FILE, ">> $configfile" ) or die "Unable to write $configfile";
print FILE <<END
$outfwsettings{'STATE'};$outfwsettings{'ENABLED'};$outfwsettings{'SNET'};$outfwsettings{'PROT'};$outfwsettings{'NAME'};$outfwsettings{'SIP'};$outfwsettings{'SMAC'};$outfwsettings{'DIP'};$outfwsettings{'DPORT'};
END
;
close FILE;
} else {
$outfwsettings{'ACTION'} = 'Regel hinzufuegen';
}
}
if ($outfwsettings{'ACTION'} eq 'Regel hinzufuegen')
{
&addrule();
exit
}
&General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<class name='base'>$errormessage\n";
print "&nbsp;</class>\n";
&Header::closebox();
}
############################################################################################################################
############################################################################################################################
if ($outfwsettings{'POLICY'} ne 'MODE0'){
&Header::openbox('100%', 'center', 'Rules');
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='submit' name='ACTION' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)' value='Regel hinzufuegen'>
END
;
open( FILE, "< $configfile" ) or die "Unable to read $configfile";
@configs = <FILE>;
close FILE;
if (@configs) {
print <<END
<hr>
<table border='0' width='100%' cellspacing='0'>
<tr><td bgcolor='lightgrey' width='14%'>Protokoll
<td bgcolor='lightgrey' width='14%'>Netzwerk
<td bgcolor='lightgrey' width='14%'>Ziel
<td bgcolor='lightgrey' width='14%'>Anmerkung
<td bgcolor='lightgrey' width='14%'>Politik
<td bgcolor='lightgrey' width='30%'>Aktionen
END
;
foreach $configentry (sort @configs)
{
@configline = split( /\;/, $configentry );
$outfwsettings{'STATE'} = $configline[0];
$outfwsettings{'ENABLED'} = $configline[1];
$outfwsettings{'SNET'} = $configline[2];
$outfwsettings{'PROT'} = $configline[3];
$outfwsettings{'NAME'} = $configline[4];
$outfwsettings{'SIP'} = $configline[5];
$outfwsettings{'SMAC'} = $configline[6];
$outfwsettings{'DIP'} = $configline[7];
$outfwsettings{'DPORT'} = $configline[8];
if ($outfwsettings{'DIP'} eq ''){ $outfwsettings{'DISPLAY_DIP'} = 'ALL'; } else { $outfwsettings{'DISPLAY_DIP'} = $outfwsettings{'DIP'}; }
if ($outfwsettings{'DPORT'} eq ''){ $outfwsettings{'DISPLAY_DPORT'} = 'ALL'; } else { $outfwsettings{'DISPLAY_DPORT'} = $outfwsettings{'DPORT'}; }
if ($outfwsettings{'STATE'} eq 'DENY'){ $outfwsettings{'DISPLAY_STATE'} = "<img src='/images/stock_stop.png' alt='DENY'>"; }
if ($outfwsettings{'STATE'} eq 'ALLOW'){ $outfwsettings{'DISPLAY_STATE'} = "<img src='/images/stock_ok.png' alt='ALLOW'>"; }
if ((($outfwsettings{'POLICY'} eq 'MODE1') && ($outfwsettings{'STATE'} eq 'ALLOW')) || (($outfwsettings{'POLICY'} eq 'MODE2') && ($outfwsettings{'STATE'} eq 'DENY'))){
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='PROT' value=$outfwsettings{'PROT'}>
<input type='hidden' name='STATE' value=$outfwsettings{'STATE'}>
<input type='hidden' name='SNET' value=$outfwsettings{'SNET'}>
<input type='hidden' name='DPORT' value=$outfwsettings{'DPORT'}>
<input type='hidden' name='DIP' value=$outfwsettings{'DIP'}>
<input type='hidden' name='SIP' value=$outfwsettings{'SIP'}>
<input type='hidden' name='NAME' value=$outfwsettings{'NAME'}>
<input type='hidden' name='SMAC' value=$outfwsettings{'SMAC'}>
<input type='hidden' name='ENABLED' value=$outfwsettings{'ENABLED'}>
<tr><td align='center' bgcolor='#EAEAEA'>$outfwsettings{'PROT'}
<td align='center' bgcolor='#EAEAEA'>$outfwsettings{'SNET'}
<td align='center' bgcolor='#EAEAEA'>$outfwsettings{'DISPLAY_DIP'}:$outfwsettings{'DISPLAY_DPORT'}
<td align='center' bgcolor='#EAEAEA'>$outfwsettings{'NAME'}
<td align='center' bgcolor='#EAEAEA'>$outfwsettings{'DISPLAY_STATE'}
<td align='right' bgcolor='#EAEAEA'>
<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>&nbsp;
<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>
END
;
if (($outfwsettings{'SIP'}) || ($outfwsettings{'SMAC'})) {
unless ($outfwsettings{'SIP'}) { $outfwsettings{'DISPLAY_SIP'} = '---'; } else { $outfwsettings{'DISPLAY_SIP'} = $outfwsettings{'SIP'}; }
unless ($outfwsettings{'SMAC'}) { $outfwsettings{'DISPLAY_SMAC'} = '---'; } else { $outfwsettings{'DISPLAY_SMAC'} = $outfwsettings{'SMAC'}; }
print <<END
<tr><td width='14%' align='right' bgcolor='#FAFAFA'>Quell-IP-Adresse:
<td width='14%' align='left' bgcolor='#FAFAFA'>$outfwsettings{'DISPLAY_SIP'}
<td width='14%' align='right' bgcolor='#FAFAFA'>Quell-MAC-Adresse:
<td width='14%' align='left' bgcolor='#FAFAFA'>$outfwsettings{'DISPLAY_SMAC'}
<td width='44%' colspan='2' align='center' bgcolor='#FAFAFA'>
END
;
}
print <<END
</form>
END
;
}
}
print <<END
</table>
END
;
}
print <<END
</form>
END
;
&Header::closebox();
}
if ($outfwsettings{'POLICY'} eq 'MODE2'){
open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
@p2ps = <FILE>;
close FILE;
&Header::openbox('100%', 'center', 'P2P-Block');
print <<END
<table width='40%'>
<tr><td bgcolor='lightgrey' width='66%'>Protokoll
<td bgcolor='lightgrey' width='33%'>Status
END
;
foreach $p2pentry (sort @p2ps)
{
@p2pline = split( /\;/, $p2pentry );
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<tr><td width='66%' align='center'>$p2pline[0]:
<td width='33%' align='center'><input type='hidden' name='P2PROT' value=$p2pline[1]>
END
;
if ($p2pline[2] eq 'on') {
print <<END
<input type='hidden' name='ACTION' value='disable'>
<input type='image' name='submit' src='/images/stock_ok.png' alt=''>
END
;
} else {
print <<END
<input type='hidden' name='ACTION' value='enable'>
<input type='image' name='submit' src='/images/stock_stop.png' alt=''>
END
;
}
print <<END
</form>
END
;
}
print <<END
<tr><td colspan='2' align='center'>Klicken Sie auf die Symbole um das entsprechende P2P-Netz zu (de-)aktivieren.
</table>
END
;
&Header::closebox();
}
&Header::openbox('100%', 'center', 'Policy');
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<table width='100%'>
<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.
<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.
<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.
<tr><td colspan='3'><hr>
<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>
<td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'}>
<td width='45%' align='right'>
END
;
if ($outfwsettings{'POLICY'} ne 'MODE0') {
print <<END
Alle Regeln loeschen: <input type='submit' name='ACTION' value=$Lang::tr{'reset'}>
END
;
}
print <<END
</table>
</form>
END
;
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
############################################################################################################################
############################################################################################################################
sub addrule
{
&Header::openbox('100%', 'center', 'Rules hinzufuegen');
if ($outfwsettings{'EDIT'} eq 'no') { $selected{'ENABLED'} = 'checked'; }
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<table width='80%'>
<tr><td width='20%' align='right'>Anmerkung: <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='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='udp' $selected{'PROT'}{'UDP'}>UDP</option></select>
<td width='20%' align='right'>Sicherheitspolitik:
<td width='30%' align='left'>
END
;
if ($outfwsettings{'POLICY'} eq 'MODE1'){
print "\t\t\tALLOW<input type='hidden' name='STATE' value='ALLOW'>\n";
} elsif ($outfwsettings{'POLICY'} eq 'MODE2'){
print "\t\t\tDENY<input type='hidden' name='STATE' value='DENY'>\n";
}
print <<END
<tr><td width='20%' align='right'>Quellnetz:
<td width='30%' align='left'><select name='SNET'>
<option value='all' $selected{'SNET'}{'ALL'}>alle</option>
<option value='green' $selected{'SNET'}{'GREEN'}>Gruen</option>
END
;
if (&Header::blue_used()){
print "\t\t\t<option value='blue' $selected{'SNET'}{'BLUE'}>Blau</option>\n";
}
if (&Header::orange_used()){
print "\t\t\t<option value='orange' $selected{'SNET'}{'ORANGE'}>Orange</option>\n";
}
print <<END
</select>
<td width='20%' align='right'>Quell-IP-Adresse: <img src='/blob.gif'>
<td width='30%' align='left'><input type='text' name='SIP' maxlength='15' value='$outfwsettings{'SIP'}'>
<tr><td width='50%' colspan='2'>&nbsp;
<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'>
<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='30%' align='left'><input type='text' name='DPORT' maxlength='5' 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'}
<td width='60%' align='left' colspan='2'><input type='submit' name='ACTION' value=$Lang::tr{'add'}>
</table></form>
END
;
&Header::closebox();
}

View File

@@ -1475,6 +1475,7 @@
'urlfilter update notification' => 'Update-Benachrichtigung!',
'urlfilter update information' => 'Eine aktualisierte Version steht zum Download bereit. Besuchen Sie <a href="http://www.urlfilter.net" target="_blank">http://www.urlfilter.net</a> für weitere Informationen.',
'display webinterface effects' => 'Überblendeffekte einschalten',
'outgoing firewall' => 'Ausgehende Firewall',
);

View File

@@ -1508,5 +1508,6 @@
'urlfilter update notification' => 'Update notification!',
'urlfilter update information' => 'There is an updated version available for download. Visit <a href="http://www.urlfilter.net" target="_blank">http://www.urlfilter.net</a> for more information.',
'display webinterface effects' => 'Activate effects',
'outgoing firewall' => 'Outgoing Firewall',
);

View File

@@ -51,7 +51,7 @@ $(TARGET) :
# Create all directories
for i in addon-lang alcatelusb auth backup backup/sets ca certs cnx_pci crls ddns dhcp dhcpc dmzholes \
eagle-usb eciadsl ethernet isdn key langs logging main modem net-traffic nfs optionsfw patches pakfire portfw \
eagle-usb eciadsl ethernet isdn key langs logging main modem net-traffic nfs optionsfw outgoing patches pakfire portfw \
ppp private proxy/advanced qos/bin red remote snort time urlfilter/autoupdate urlfilter/bin vpn wireless xtaccess ; do \
mkdir -p $(CONFIG_ROOT)/$$i; \
done
@@ -60,7 +60,7 @@ $(TARGET) :
for i in auth/users backup/include.user backup/exclude.user \
certs/index.txt ddns/config ddns/noipsettings ddns/settings ddns/ipcache dhcp/settings \
dhcp/fixleases dhcp/advoptions dmzholes/config ethernet/aliases ethernet/settings \
isdn/settings main/hosts main/settings optionsfw/settings pakfire/settings patches/available patches/installed \
isdn/settings main/hosts main/settings optionsfw/settings outgoing/settings outgoing/rules pakfire/settings patches/available patches/installed \
portfw/config ppp/settings-1 ppp/settings-2 ppp/settings-3 ppp/settings-4 \
ppp/settings-5 ppp/settings proxy/settings remote/settings qos/settings qos/classes qos/subclasses qos/level7config qos/portconfig \
snort/settings vpn/config vpn/settings vpn/ipsec.conf \
@@ -81,6 +81,7 @@ $(TARGET) :
cp $(DIR_SRC)/config/cfgroot/modem-settings $(CONFIG_ROOT)/modem/settings
cp $(DIR_SRC)/config/cfgroot/net-traffic-lib.pl $(CONFIG_ROOT)/net-traffic/net-traffic-lib.pl
cp $(DIR_SRC)/config/cfgroot/nfs-server $(CONFIG_ROOT)/nfs/nfs-server
cp $(DIR_SRC)/config/cfgroot/p2protocols $(CONFIG_ROOT)/outgoing/p2protocols
cp $(DIR_SRC)/config/cfgroot/proxy-acl $(CONFIG_ROOT)/proxy/acl-1.4
cp $(DIR_SRC)/config/qos/makeqosscripts.pl $(CONFIG_ROOT)/qos/bin/makeqosscripts.pl
cp $(DIR_SRC)/config/cfgroot/ssh-settings $(CONFIG_ROOT)/remote/settings

View File

@@ -21054,6 +21054,7 @@ home/httpd/cgi-bin/modem.cgi
home/httpd/cgi-bin/netstatus.cgi
#home/httpd/cgi-bin/networks.cgi
home/httpd/cgi-bin/optionsfw.cgi
home/httpd/cgi-bin/outgoingfw.cgi
home/httpd/cgi-bin/portfw.cgi
home/httpd/cgi-bin/pppsetup.cgi
#home/httpd/cgi-bin/printenv