From: Alexander Marx Date: Thu, 21 Mar 2013 09:35:07 +0000 (+0100) Subject: Forward Firewall: Fix converter-outgoingfw. Produced wrong counters while converting X-Git-Url: http://git.ipfire.org/?p=people%2Fteissler%2Fipfire-2.x.git;a=commitdiff_plain;h=8343fd125091b3530a76609e8ec17dbf9f63ed69 Forward Firewall: Fix converter-outgoingfw. Produced wrong counters while converting --- diff --git a/config/forwardfw/convert-outgoingfw b/config/forwardfw/convert-outgoingfw index f220738a6..d065b5acd 100755 --- a/config/forwardfw/convert-outgoingfw +++ b/config/forwardfw/convert-outgoingfw @@ -1,5 +1,17 @@ #!/usr/bin/perl - +######################################################################## +# Script: convert-outgoingfw +# Date: 21.03.2013 +# Author: Alexander Marx (amarx@ipfire.org) +######################################################################## +# +# This script converts old groups and firewallrules +# to the new one. This is a 3-step process. +# STEP1: convert groups ->LOG /var/log/converters +# STEP2: convert rules ->LOG /var/log/converters +# STEP3: convert P2P rules +# +######################################################################## require '/var/ipfire/general-functions.pl'; @@ -35,10 +47,12 @@ my %fwconfig=(); my %fwconfigout=(); my %fwdsettings=(); &General::readhash($outfwsettings,\%outsettings); - -&process_groups; -&process_rules; -&process_p2p; +#ONLY RUN if /var/ipfire/outgoing exists +if ( -d "/var/ipfire/outgoing"){ + &process_groups; + &process_rules; + &process_p2p; +} system("/usr/local/bin/forwardfwctrl"); sub process_groups { @@ -152,6 +166,13 @@ sub new_hostgrp print LOG "->Host (IP) $ip already exists in custom hosts\n"; $name="host "; $name2=$name.$ippart; + foreach my $key (sort keys %hosts){ + if($hosts{$key}[0] eq $name2){ + $hosts{$key}[4]++; + } + } + $name="host "; + $name2=$name.$ippart; $name3="Custom Host"; } }elsif($byte4 < '255'){ @@ -171,6 +192,13 @@ sub new_hostgrp print LOG "Network $ippart already exists in custom networks\n"; $name="net "; $name2=$name.$ippart; + foreach my $key (sort keys %nets){ + if($nets{$key}[0] eq $name2){ + $nets{$key}[4]++; + } + } + $name="net "; + $name2=$name.$ippart; $name3="Custom Network"; } } @@ -202,6 +230,13 @@ sub new_hostgrp print LOG "->Host (MAC) $mac already exists in custom hosts \n"; $name="host "; $name2=$name.$mac; + foreach my $key (sort keys %hosts){ + if($hosts{$key}[0] eq $name2){ + $hosts{$key}[4]++; + } + } + $name="host "; + $name2=$name.$mac; $name3="Custom Host"; } if($name2 && !&check_grp($grp,$name2)){