###############################################################################
# #
# 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 #
$outfwsettings{'DISPLAY_SMAC'} = '';
$outfwsettings{'DISPLAY_SIP'} = '';
$outfwsettings{'POLICY'} = 'MODE0';
+
my $SOURCE = "";
my $DESTINATION = "";
my $PROTO = "";
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 = <FILE>;
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'};
@proto = ("tcp");
} elsif ($configline[3] eq 'udp') {
@proto = ("udp");
+ } elsif ($configline[3] eq 'esp') {
+ @proto = ("esp");
+ } elsif ($configline[3] eq 'gre') {
+ @proto = ("gre");
} else {
- @proto = ("tcp", "udp");
+ @proto = ("tcp","udp");
}
+
foreach $PROTO (@proto) {
$CMD = "/sbin/iptables -A OUTGOINGFW -s $SOURCE -d $DESTINATION -p $PROTO";
- if ($configline[8]) {
+ if ($configline[8] && $configline[3] ne 'esp' && $configline[3] ne 'gre') {
$DPORT = "$configline[8]";
$CMD = "$CMD --dport $DPORT";
- }
+ }
if ($DEV) {
$CMD = "$CMD -i $DEV";
$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") {
} else {
system("$CMD");
}
-}
+}
\ No newline at end of file