From 39008af71dee1f65a7f424cb04a9594b4a7ea4b4 Mon Sep 17 00:00:00 2001 From: Christian Schmidt Date: Sun, 6 Dec 2009 19:22:28 +0100 Subject: [PATCH] Added enhancements for outgoing fw to core34. --- config/outgoingfw/outgoingfw.pl | 23 ++- config/rootfiles/core/34/filelists/files | 4 +- html/cgi-bin/outgoingfw.cgi | 185 ++++++++++++++++++++--- 3 files changed, 187 insertions(+), 25 deletions(-) diff --git a/config/outgoingfw/outgoingfw.pl b/config/outgoingfw/outgoingfw.pl index ae1f105e27..ec89e873bd 100644 --- a/config/outgoingfw/outgoingfw.pl +++ b/config/outgoingfw/outgoingfw.pl @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# Copyright (C) 2009 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 # @@ -64,6 +64,7 @@ $outfwsettings{'DISPLAY_DPORT'} = ''; $outfwsettings{'DISPLAY_SMAC'} = ''; $outfwsettings{'DISPLAY_SIP'} = ''; $outfwsettings{'POLICY'} = 'MODE0'; + my $SOURCE = ""; my $DESTINATION = ""; my $PROTO = ""; @@ -72,12 +73,14 @@ my $DEV = ""; my $MAC = ""; my $POLICY = ""; my $DO = ""; +my $DAY = ""; # read files &General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings); &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); $netsettings{'RED_DEV'}=`cat /var/ipfire/red/iface`; +$netsettings{'RED_IP'}=`cat /var/ipfire/red/local-ipaddress`; open( FILE, "< $configfile" ) or die "Unable to read $configfile"; @configs = ; @@ -122,6 +125,9 @@ foreach $configentry (sort @configs) if ($configline[2] eq 'green') { $SOURCE = "$netsettings{'GREEN_NETADDRESS'}/$netsettings{'GREEN_NETMASK'}"; $DEV = $netsettings{'GREEN_DEV'}; + } elsif ($configline[2] eq 'red') { + $SOURCE = "$netsettings{'RED_IP'}"; + $DEV = ""; } elsif ($configline[2] eq 'blue') { $SOURCE = "$netsettings{'BLUE_NETADDRESS'}/$netsettings{'BLUE_NETMASK'}"; $DEV = $netsettings{'BLUE_DEV'}; @@ -142,8 +148,6 @@ foreach $configentry (sort @configs) @proto = ("tcp"); } elsif ($configline[3] eq 'udp') { @proto = ("udp"); - } elsif ($configline[3] eq 'all') { - @proto = ("all"); } else { @proto = ("tcp", "udp"); } @@ -165,6 +169,17 @@ foreach $configentry (sort @configs) $CMD = "$CMD -m mac --mac-source $MAC"; } + if ($configline[17] && $configline[18]) { + if ($configline[10]){$DAY = "Mon,"} + if ($configline[11]){$DAY .= "Tue,"} + if ($configline[12]){$DAY .= "Wed,"} + if ($configline[13]){$DAY .= "Thu,"} + if ($configline[14]){$DAY .= "Fri,"} + if ($configline[15]){$DAY .= "Sat,"} + if ($configline[16]){$DAY .= "Sun"} + $CMD = "$CMD -m time --timestart $configline[17] --timestop $configline[18] --weekdays $DAY"; + } + $CMD = "$CMD -o $netsettings{'RED_DEV'}"; if ($configline[9] eq "aktiv") { @@ -230,4 +245,4 @@ if ( $outfwsettings{'POLICY'} eq 'MODE1' ) { } else { system("$CMD"); } -} +} \ No newline at end of file diff --git a/config/rootfiles/core/34/filelists/files b/config/rootfiles/core/34/filelists/files index 2c663e1c94..c59b8d8863 100644 --- a/config/rootfiles/core/34/filelists/files +++ b/config/rootfiles/core/34/filelists/files @@ -6,8 +6,10 @@ srv/web/ipfire/cgi-bin/index.cgi srv/web/ipfire/cgi-bin/mac.cgi srv/web/ipfire/cgi-bin/extrahd.cgi srv/web/ipfire/cgi-bin/chpasswd.cgi +srv/web/ipfire/cgi-bin/outgoingfw.cgi var/ipfire/langs/en.pl var/ipfire/langs/de.pl var/ipfire/langs/fr.pl var/ipfire/langs/list -usr/local/sbin/setup +var/ipfire/outgoing/bin/outgoingfw.pl +usr/local/sbin/setup \ No newline at end of file diff --git a/html/cgi-bin/outgoingfw.cgi b/html/cgi-bin/outgoingfw.cgi index 8988c9a1a6..f3cf581a6a 100644 --- a/html/cgi-bin/outgoingfw.cgi +++ b/html/cgi-bin/outgoingfw.cgi @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# Copyright (C) 2009 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 # @@ -21,8 +21,8 @@ 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"; @@ -73,12 +73,39 @@ $outfwsettings{'DISPLAY_SIP'} = ''; $outfwsettings{'POLICY'} = 'MODE0'; $outfwsettings{'MODE1LOG'} = 'off'; +$outfwsettings{'TIME_FROM'} = '00:00'; +$outfwsettings{'TIME_TO'} = '00:00'; + &General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings); &Header::getcgihash(\%outfwsettings); +$selected{'TIME_FROM'}{$outfwsettings{'TIME_FROM'}} = "selected='selected'"; +$selected{'TIME_TO'}{$outfwsettings{'TIME_TO'}} = "selected='selected'"; + $checked{'MODE1LOG'}{'off'} = ''; $checked{'MODE1LOG'}{'on'} = ''; $checked{'MODE1LOG'}{$outfwsettings{'MODE1LOG'}} = "checked='checked'"; +$checked{'TIME_MON'}{'off'} = ''; +$checked{'TIME_MON'}{'on'} = ''; +$checked{'TIME_MON'}{$outfwsettings{'TIME_MON'}} = "checked='checked'"; +$checked{'TIME_TUE'}{'off'} = ''; +$checked{'TIME_TUE'}{'on'} = ''; +$checked{'TIME_TUE'}{$outfwsettings{'TIME_TUE'}} = "checked='checked'"; +$checked{'TIME_WED'}{'off'} = ''; +$checked{'TIME_WED'}{'on'} = ''; +$checked{'TIME_WED'}{$outfwsettings{'TIME_WED'}} = "checked='checked'"; +$checked{'TIME_THU'}{'off'} = ''; +$checked{'TIME_THU'}{'on'} = ''; +$checked{'TIME_THU'}{$outfwsettings{'TIME_THU'}} = "checked='checked'"; +$checked{'TIME_FRI'}{'off'} = ''; +$checked{'TIME_FRI'}{'on'} = ''; +$checked{'TIME_FRI'}{$outfwsettings{'TIME_FRI'}} = "checked='checked'"; +$checked{'TIME_SAT'}{'off'} = ''; +$checked{'TIME_SAT'}{'on'} = ''; +$checked{'TIME_SAT'}{$outfwsettings{'TIME_SAT'}} = "checked='checked'"; +$checked{'TIME_SUN'}{'off'} = ''; +$checked{'TIME_SUN'}{'on'} = ''; +$checked{'TIME_SUN'}{$outfwsettings{'TIME_SUN'}} = "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'} = ''; } @@ -164,7 +191,16 @@ if ($outfwsettings{'ACTION'} eq $Lang::tr{'edit'}) ($configline[6] eq $outfwsettings{'SMAC'}) && ($configline[7] eq $outfwsettings{'DIP'}) && ($configline[9] eq $outfwsettings{'LOG'}) && - ($configline[8] eq $outfwsettings{'DPORT'})) + ($configline[8] eq $outfwsettings{'DPORT'}) && + ($configline[10] eq $outfwsettings{'TIME_MON'}) && + ($configline[11] eq $outfwsettings{'TIME_TUE'}) && + ($configline[12] eq $outfwsettings{'TIME_WED'}) && + ($configline[13] eq $outfwsettings{'TIME_THU'}) && + ($configline[14] eq $outfwsettings{'TIME_FRI'}) && + ($configline[15] eq $outfwsettings{'TIME_SAT'}) && + ($configline[16] eq $outfwsettings{'TIME_SUN'}) && + ($configline[17] eq $outfwsettings{'TIME_FROM'}) && + ($configline[18] eq $outfwsettings{'TIME_TO'})) { print FILE $configentry; } @@ -197,7 +233,16 @@ if ($outfwsettings{'ACTION'} eq $Lang::tr{'delete'}) ($configline[6] eq $outfwsettings{'SMAC'}) && ($configline[7] eq $outfwsettings{'DIP'}) && ($configline[9] eq $outfwsettings{'LOG'}) && - ($configline[8] eq $outfwsettings{'DPORT'})) + ($configline[8] eq $outfwsettings{'DPORT'}) && + ($configline[10] eq $outfwsettings{'TIME_MON'}) && + ($configline[11] eq $outfwsettings{'TIME_TUE'}) && + ($configline[12] eq $outfwsettings{'TIME_WED'}) && + ($configline[13] eq $outfwsettings{'TIME_THU'}) && + ($configline[14] eq $outfwsettings{'TIME_FRI'}) && + ($configline[15] eq $outfwsettings{'TIME_SAT'}) && + ($configline[16] eq $outfwsettings{'TIME_SUN'}) && + ($configline[17] eq $outfwsettings{'TIME_FROM'}) && + ($configline[18] eq $outfwsettings{'TIME_TO'})) { print FILE $configentry; } @@ -210,7 +255,7 @@ if ($outfwsettings{'ACTION'} eq $Lang::tr{'add'}) if ( $outfwsettings{'VALID'} eq 'yes' ) { open( FILE, ">> $configfile" ) or die "Unable to write $configfile"; print FILE < + + + + + + + + + @@ -315,6 +379,15 @@ END + + + + + + + + + @@ -330,7 +403,36 @@ END END ; } - print <$Lang::tr{'time'} - + +END +; + if ($outfwsettings{'TIME_MON'} eq 'on') { print "";} + else { print "";} + print "$Lang::tr{'advproxy monday'},"; + if ($outfwsettings{'TIME_TUE'} eq 'on') { print "";} + else { print "";} + print "$Lang::tr{'advproxy tuesday'},"; + if ($outfwsettings{'TIME_WED'} eq 'on') { print "";} + else { print "";} + print "$Lang::tr{'advproxy wednesday'},"; + if ($outfwsettings{'TIME_THU'} eq 'on') { print "";} + else { print "";} + print "$Lang::tr{'advproxy thursday'},"; + if ($outfwsettings{'TIME_FRI'} eq 'on') { print "";} + else { print "";} + print "$Lang::tr{'advproxy friday'},"; + if ($outfwsettings{'TIME_SAT'} eq 'on') { print "";} + else { print "";} + print "$Lang::tr{'advproxy saturday'},"; + if ($outfwsettings{'TIME_SUN'} eq 'on') { print "";} + else { print "";} + print "$Lang::tr{'advproxy sunday'}"; + print < + $Lang::tr{'advproxy from'} $outfwsettings{'TIME_FROM'} + $Lang::tr{'advproxy to'} $outfwsettings{'TIME_TO'} END ; @@ -448,17 +550,19 @@ sub addrule { &Header::openbox('100%', 'center', 'Rules hinzufuegen'); if ($outfwsettings{'EDIT'} eq 'no') { $selected{'ENABLED'} = 'checked'; } + $selected{'TIME_FROM'}{$outfwsettings{'TIME_FROM'}} = "selected='selected'"; + $selected{'TIME_TO'}{$outfwsettings{'TIME_TO'}} = "selected='selected'"; print < "; } print < - + + + + + + + +
$Lang::tr{'description'}: - $Lang::tr{'active'}: - + $Lang::tr{'active'}: +
$Lang::tr{'protocol'}: - $Lang::tr{'policy'}: - + $Lang::tr{'policy'}: + END ; if ($outfwsettings{'POLICY'} eq 'MODE1'){ @@ -471,6 +575,7 @@ END $Lang::tr{'source ip'}: - + $Lang::tr{'source ip'}: +
$Lang::tr{'logging'}: END ; @@ -494,15 +599,55 @@ else{ print " + +
$Lang::tr{'destination ip'}: - $Lang::tr{'destination port'}: - -
+ $Lang::tr{'destination port'}: + +
$Lang::tr{'time'}:$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'} + $Lang::tr{'advproxy from'}$Lang::tr{'advproxy to'}
+ + + + + + +
$Lang::tr{'this field may be blank'} - +
END ; @@ -549,4 +694,4 @@ END print ""; &Header::closebox(); } -} +} \ No newline at end of file -- 2.39.2