From e5a058c131806586e53c44d5ecca7e1d4a926f84 Mon Sep 17 00:00:00 2001 From: Alexander Marx Date: Tue, 19 Feb 2013 15:24:24 +0100 Subject: [PATCH] FORWARD FIREWALL: added remark in custom networks --- html/cgi-bin/fwhosts.cgi | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/html/cgi-bin/fwhosts.cgi b/html/cgi-bin/fwhosts.cgi index 90e1fb305..5bba69e53 100755 --- a/html/cgi-bin/fwhosts.cgi +++ b/html/cgi-bin/fwhosts.cgi @@ -96,7 +96,8 @@ if ($fwhostsettings{'ACTION'} eq 'updatenet' ) $fwhostsettings{'orgname'} = $customnetwork{$key}[0]; $fwhostsettings{'orgip'} = $customnetwork{$key}[1]; $fwhostsettings{'orgsub'} = $customnetwork{$key}[2]; - $fwhostsettings{'count'} = $customnetwork{$key}[3]; + $fwhostsettings{'netremark'} = $customnetwork{$key}[3]; + $fwhostsettings{'count'} = $customnetwork{$key}[4]; delete $customnetwork{$key}; } @@ -230,6 +231,11 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' ) $fwhostsettings{'NOCHECK'} ='false'; $fwhostsettings{'error'} ='on'; } + #check remark + if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark($fwhostsettings{'NETREMARK'})){ + $errormessage=$Lang::tr{'fwhost err remark'}; + $fwhostsettings{'error'} ='on'; + } #check if subnet is sigle host if(&General::iporsubtocidr($fwhostsettings{'SUBNET'}) eq '32') { @@ -280,17 +286,19 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' ) $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ; $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ; $customnetwork{$key}[2] = $fwhostsettings{'orgsub'}; - $customnetwork{$key}[3] = $fwhostsettings{'count'}; + $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'}; + $customnetwork{$key}[4] = $fwhostsettings{'count'}; &General::writehasharray("$confignet", \%customnetwork); undef %customnetwork; } if (!$errormessage){ + &General::readhasharray("$confignet", \%customnetwork); if ($fwhostsettings{'ACTION'} eq 'updatenet'){ if ($fwhostsettings{'update'} == '0'){ foreach my $key (keys %customnetwork) { if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){ - $count=$customnetwork{$key}[3]; + $count=$customnetwork{$key}[4]; delete $customnetwork{$key}; last; } @@ -340,22 +348,24 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' ) } } my $key = &General::findhasharraykey (\%customnetwork); - foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";} + foreach my $i (0 .. 4) { $customnetwork{$key}[$i] = "";} $fwhostsettings{'SUBNET'} = &General::iporsubtocidr($fwhostsettings{'SUBNET'}); $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'}; #convert ip when leading '0' in byte - $fwhostsettings{'IP'}=&General::ip2dec($fwhostsettings{'IP'}); - $fwhostsettings{'IP'}=&General::dec2ip($fwhostsettings{'IP'}); + $fwhostsettings{'IP'} =&General::ip2dec($fwhostsettings{'IP'}); + $fwhostsettings{'IP'} =&General::dec2ip($fwhostsettings{'IP'}); $customnetwork{$key}[1] = &General::getnetworkip($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ; $customnetwork{$key}[2] = &General::iporsubtodec($fwhostsettings{'SUBNET'}) ; if($fwhostsettings{'newnet'} eq 'on'){$count=0;} - $customnetwork{$key}[3] = $count; + $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'}; + $customnetwork{$key}[4] = $count; &General::writehasharray("$confignet", \%customnetwork); $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'}); undef %customnetwork; $fwhostsettings{'HOSTNAME'}=''; $fwhostsettings{'IP'}=''; $fwhostsettings{'SUBNET'}=''; + $fwhostsettings{'NETREMARK'}=''; #check if an edited net affected groups and need to reload rules if ($needrules eq 'on'){ &rules; @@ -662,7 +672,7 @@ if ($fwhostsettings{'ACTION'} eq 'savegrp') if($updcounter eq 'net'){ foreach my $key (keys %customnetwork) { if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){ - $customnetwork{$key}[3] = $customnetwork{$key}[3]+1; + $customnetwork{$key}[4] = $customnetwork{$key}[4]+1; last; } } @@ -1092,6 +1102,7 @@ sub addnet print<
$Lang::tr{'name'}:$Lang::tr{'fwhost netaddress'}$Lang::tr{'netmask'}: + $Lang::tr{'remark'}:
END if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on') @@ -1363,7 +1374,7 @@ sub viewtablenet }else{ print< - $Lang::tr{'name'}$Lang::tr{'fwhost netaddress'}$Lang::tr{'netmask'}$Lang::tr{'used'} + $Lang::tr{'name'}$Lang::tr{'fwhost netaddress'}$Lang::tr{'netmask'}$Lang::tr{'remark'}$Lang::tr{'used'} END } my $count=0; @@ -1378,15 +1389,16 @@ END print" "; } print<$customnetwork{$key}[0]$customnetwork{$key}[1]$customnetwork{$key}[2]$customnetwork{$key}[3]x + $customnetwork{$key}[0]$customnetwork{$key}[1]$customnetwork{$key}[2]$customnetwork{$key}[3]$customnetwork{$key}[4]x + END - if($customnetwork{$key}[3] == '0') + if($customnetwork{$key}[4] == '0') { print"
"; }else{ -- 2.39.2