X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Ffwhosts.cgi;h=3b46677b8c30625e6c57b9aaba47fd2e3cf1b628;hb=7cc8a0e526d20b2bf75a68ff208a3dbf0723c552;hp=7fb05de39146c1de50b216184eb42c91d7e24896;hpb=3a162dc14f98444dd91493285c677dc295aa4c4f;p=people%2Fteissler%2Fipfire-2.x.git diff --git a/html/cgi-bin/fwhosts.cgi b/html/cgi-bin/fwhosts.cgi index 7fb05de39..3b46677b8 100755 --- a/html/cgi-bin/fwhosts.cgi +++ b/html/cgi-bin/fwhosts.cgi @@ -111,6 +111,12 @@ print< END @@ -233,20 +239,12 @@ if ($fwhostsettings{'ACTION'} eq 'updateservice') foreach my $key (sort keys %customservicegrp){ if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){ $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'}; + &checkrulereload($customservicegrp{$key}[0]); } } &General::writehasharray("$configsrvgrp", \%customservicegrp); - $needrules='on'; - } - if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){ - $needrules='on'; - } - if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){ - $needrules='on'; - } - if($count gt 0 && $fwhostsettings{'oldsrvicmp'} ne $fwhostsettings{'ICMP'} ){ - $needrules='on'; } + &checkrulereload($fwhostsettings{'SRV_NAME'}); $fwhostsettings{'SRV_NAME'} = ''; $fwhostsettings{'SRV_PORT'} = ''; $fwhostsettings{'PROT'} = ''; @@ -260,15 +258,11 @@ if ($fwhostsettings{'ACTION'} eq 'updateservice') $fwhostsettings{'ICMP'} = $fwhostsettings{'oldsrvicmp'}; $fwhostsettings{'updatesrv'}= 'on'; } - if($needrules eq 'on'){ - &General::firewall_config_changed(); - } &addservice; } # save if ($fwhostsettings{'ACTION'} eq 'savenet' ) { - my $count=0; my $needrules=0; if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};} #check if all fields are set @@ -342,7 +336,6 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' ) $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ; $customnetwork{$key}[2] = $fwhostsettings{'orgsub'}; $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'}; - $customnetwork{$key}[4] = $fwhostsettings{'count'}; &General::writehasharray("$confignet", \%customnetwork); undef %customnetwork; } @@ -353,7 +346,6 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' ) if ($fwhostsettings{'update'} == '0'){ foreach my $key (keys %customnetwork) { if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){ - $count=$customnetwork{$key}[4]; delete $customnetwork{$key}; last; } @@ -363,9 +355,8 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' ) #get count if actualize is 'on' if($fwhostsettings{'actualize'} eq 'on'){ $fwhostsettings{'actualize'} = ''; - $count=$fwhostsettings{'count'}; #check if we need to reload rules - if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){ + if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){ $needrules='on'; } if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){ @@ -403,7 +394,7 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' ) } } my $key = &General::findhasharraykey (\%customnetwork); - foreach my $i (0 .. 4) { $customnetwork{$key}[$i] = "";} + foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";} $fwhostsettings{'SUBNET'} = &General::iporsubtocidr($fwhostsettings{'SUBNET'}); $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'}; #convert ip when leading '0' in byte @@ -411,9 +402,7 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' ) $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] = $fwhostsettings{'NETREMARK'}; - $customnetwork{$key}[4] = $count; &General::writehasharray("$confignet", \%customnetwork); $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'}); undef %customnetwork; @@ -435,7 +424,6 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' ) } if ($fwhostsettings{'ACTION'} eq 'savehost') { - my $count=0; my $needrules=0; if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};} $fwhostsettings{'SUBNET'}='32'; @@ -483,7 +471,7 @@ if ($fwhostsettings{'ACTION'} eq 'savehost') if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){ $fwhostsettings{'actualize'} = ''; my $key = &General::findhasharraykey (\%customhost); - foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";} + foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";} $customhost{$key}[0] = $fwhostsettings{'orgname'} ; $customhost{$key}[1] = $fwhostsettings{'type'} ; if($customhost{$key}[1] eq 'ip'){ @@ -492,15 +480,13 @@ if ($fwhostsettings{'ACTION'} eq 'savehost') $customhost{$key}[2] = $fwhostsettings{'orgip'}; } $customhost{$key}[3] = $fwhostsettings{'orgremark'}; - $customhost{$key}[4] = $fwhostsettings{'count'}; &General::writehasharray("$confighost", \%customhost); undef %customhost; } if (!$errormessage){ #get count if host was edited if($fwhostsettings{'actualize'} eq 'on'){ - $count=$fwhostsettings{'count'}; - if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){ + if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){ $needrules='on'; } if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){ @@ -537,7 +523,7 @@ if ($fwhostsettings{'ACTION'} eq 'savehost') } } my $key = &General::findhasharraykey (\%customhost); - foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";} + foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";} $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ; $customhost{$key}[1] = $fwhostsettings{'type'} ; if ($fwhostsettings{'type'} eq 'ip'){ @@ -548,9 +534,7 @@ if ($fwhostsettings{'ACTION'} eq 'savehost') }else{ $customhost{$key}[2] = $fwhostsettings{'IP'}; } - if($fwhostsettings{'newhost'} eq 'on'){$count=0;} $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'}; - $customhost{$key}[4] =$count; &General::writehasharray("$confighost", \%customhost); undef %customhost; $fwhostsettings{'HOSTNAME'}=''; @@ -571,7 +555,7 @@ if ($fwhostsettings{'ACTION'} eq 'savehost') } if ($fwhostsettings{'ACTION'} eq 'savegrp') { - my $grp=$fwhostsettings{'grp_name'};; + my $grp=$fwhostsettings{'grp_name'}; my $rem=$fwhostsettings{'remark'}; my $count; my $type; @@ -581,6 +565,9 @@ if ($fwhostsettings{'ACTION'} eq 'savegrp') &General::readhasharray("$configgrp", \%customgrp); &General::readhasharray("$confignet", \%customnetwork); &General::readhasharray("$confighost", \%customhost); + &General::readhasharray("$fwconfigfwd", \%fwfwd); + &General::readhasharray("$fwconfiginp", \%fwinp); + &General::readhasharray("$fwconfigout", \%fwout); #check name if (!&validhostname($grp)){$errormessage.=$Lang::tr{'fwhost err name'};} #check existing name @@ -685,17 +672,6 @@ if ($fwhostsettings{'ACTION'} eq 'savegrp') } &General::writehasharray("$configgrp", \%customgrp); &General::readhasharray("$configgrp", \%customgrp); - #get count used - foreach my $key (keys %customgrp) - { - if($customgrp{$key}[0] eq $grp) - { - $count=$customgrp{$key}[4]; - last; - } - } - if ($count eq '' ){$count='0';} - #create array with new lines foreach my $line (@target){ push (@newgrp,"$grp,$rem,$line"); @@ -703,36 +679,21 @@ if ($fwhostsettings{'ACTION'} eq 'savegrp') #append new entries my $key = &General::findhasharraykey (\%customgrp); foreach my $line (@newgrp){ - foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";} + foreach my $i (0 .. 3) { $customgrp{$key}[$i] = "";} my ($a,$b,$c,$d) = split (",",$line); $customgrp{$key}[0] = $a; $customgrp{$key}[1] = $b; $customgrp{$key}[2] = $c; $customgrp{$key}[3] = $type; - $customgrp{$key}[4] = $count; } &General::writehasharray("$configgrp", \%customgrp); #update counter in Host/Net - if($updcounter eq 'net'){ - foreach my $key (keys %customnetwork) { - if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){ - $customnetwork{$key}[4] = $customnetwork{$key}[4]+1; - last; - } - } - &General::writehasharray("$confignet", \%customnetwork); - }elsif($updcounter eq 'host'){ - foreach my $key (keys %customhost) { - if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){ - $customhost{$key}[4]=$customhost{$key}[4]+1; - } - } - &General::writehasharray("$confighost", \%customhost); - } $fwhostsettings{'update'}='on'; } #check if ruleupdate is needed - if($count > 0 ) + my $netgrpcount=0; + $netgrpcount=&getnetcount($grp); + if($netgrpcount > 0 ) { &General::firewall_config_changed(); } @@ -779,7 +740,6 @@ if ($fwhostsettings{'ACTION'} eq 'saveservicegrp') { my $prot; my $port; - my $count=0; my $tcpcounter=0; my $udpcounter=0; &General::readhasharray("$configsrvgrp", \%customservicegrp ); @@ -846,9 +806,7 @@ if ($fwhostsettings{'ACTION'} eq 'saveservicegrp') &General::writehasharray("$configsrvgrp", \%customservicegrp ); $fwhostsettings{'updatesrvgrp'}='on'; } - if ($count gt 0){ - &General::firewall_config_changed(); - } + &checkrulereload($fwhostsettings{'SRVGRP_NAME'}); &addservicegrp; &viewtableservicegrp; } @@ -1128,6 +1086,52 @@ if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark') &addservicegrp; &viewtableservicegrp; } +if ($fwhostsettings{'ACTION'} eq 'changesrvgrpname') +{ + &General::readhasharray("$configsrvgrp", \%customservicegrp ); + if ($fwhostsettings{'oldsrvgrpname'} ne $fwhostsettings{'srvgrp'}){ + #Check new groupname + if (!&validhostname($fwhostsettings{'srvgrp'})){ + $errormessage.=$Lang::tr{'fwhost err name'}."
"; + } + if (!$errormessage){ + #Rename group in customservicegroup + foreach my $key (keys %customservicegrp) { + if($customservicegrp{$key}[0] eq $fwhostsettings{'oldsrvgrpname'}){ + $customservicegrp{$key}[0]=$fwhostsettings{'srvgrp'}; + } + } + &General::writehasharray("$configsrvgrp", \%customservicegrp ); + #change name in FW Rules + &changenameinfw($fwhostsettings{'oldsrvgrpname'},$fwhostsettings{'srvgrp'},15); + } + } + &addservicegrp; + &viewtableservicegrp; +} +if ($fwhostsettings{'ACTION'} eq 'changegrpname') +{ + &General::readhasharray("$configgrp", \%customgrp ); + if ($fwhostsettings{'oldgrpname'} ne $fwhostsettings{'grp'}){ + #Check new groupname + if (!&validhostname($fwhostsettings{'grp'})){ + $errormessage.=$Lang::tr{'fwhost err name'}."
"; + } + if (!$errormessage){ + #Rename group in customservicegroup + foreach my $key (keys %customgrp) { + if($customgrp{$key}[0] eq $fwhostsettings{'oldgrpname'}){ + $customgrp{$key}[0]=$fwhostsettings{'grp'}; + } + } + &General::writehasharray("$configgrp", \%customgrp ); + #change name in FW Rules + &changenameinfw($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},6); + } + } + &addgrp; + &viewtablegrp; +} ### VIEW ### if($fwhostsettings{'ACTION'} eq '') { @@ -1155,7 +1159,7 @@ sub addnet $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'}; $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'}; print< + @@ -1164,10 +1168,10 @@ sub addnet END if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on') { - print ""; + print "
$Lang::tr{'name'}:
$Lang::tr{'fwhost netaddress'}:
$Lang::tr{'netmask'}:
"; }else{ - print ""; - } + print ""; + } print "
"; &Header::closebox(); } @@ -1215,6 +1219,7 @@ sub addgrp $checked{'check1'}{'on'} = ''; $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED'; $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'}; + $fwhostsettings{'oldgrpname'}=$fwhostsettings{'grp_name'}; my $grp=$fwhostsettings{'grp_name'}; my $rem=$fwhostsettings{'remark'}; if ($fwhostsettings{'update'} eq ''){ @@ -1227,8 +1232,8 @@ END }else{ print<
- $Lang::tr{'fwhost addgrpname'} - $Lang::tr{'remark'}:
+ $Lang::tr{'fwhost addgrpname'} +
$Lang::tr{'remark'}:

END } @@ -1392,6 +1397,7 @@ sub addservicegrp &showmenu; &Header::openbox('100%', 'left', $Lang::tr{'fwhost addservicegrp'}); $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'}; + $fwhostsettings{'oldsrvgrpname'}=$fwhostsettings{'SRVGRP_NAME'}; if ($fwhostsettings{'updatesrvgrp'} eq ''){ print<
@@ -1403,9 +1409,9 @@ END }else{ print< - $Lang::tr{'fwhost addgrpname'} - $Lang::tr{'remark'}: -

+ $Lang::tr{'fwhost addgrpname'} +
$Lang::tr{'remark'}: +

END } @@ -1450,30 +1456,39 @@ sub viewtablenet if(! -z $confignet){ &Header::openbox('100%', 'left', $Lang::tr{'fwhost cust net'}); &General::readhasharray("$confignet", \%customnetwork); + &General::readhasharray("$configgrp", \%customgrp); + &General::readhasharray("$fwconfigfwd", \%fwfwd); + &General::readhasharray("$fwconfiginp", \%fwinp); + &General::readhasharray("$fwconfigout", \%fwout); if (!keys %customnetwork) { print "
$Lang::tr{'fwhost empty'}"; }else{ print< - $Lang::tr{'name'}$Lang::tr{'fwhost netaddress'}$Lang::tr{'remark'}$Lang::tr{'used'} + + END } my $count=0; + my $col=''; foreach my $key (sort {ncmp($a,$b)} keys %customnetwork) { if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) { - print" "; + print" "; + $col="bgcolor='${Header::colouryellow}'"; }elsif ($count % 2) { - print" "; + $col="bgcolor='$color{'color20'}'"; + print" ";# bgcolor='$color{'color20'}'>"; }else { - print" "; + $col="bgcolor='$color{'color22'}'"; + print" ";# bgcolor='$color{'color22'}'>"; } my $colnet="$customnetwork{$key}[1]/".&General::subtocidr($customnetwork{$key}[2]); - print""; + my $netcount=&getnetcount($customnetwork{$key}[0]); + print""; print< + END - if($customnetwork{$key}[4] == '0') + if($netcount == '0') { - print""; + print""; }else{ - print""; + print""; } $count++; } @@ -1549,26 +1564,39 @@ sub viewtablehost &General::readhasharray("$confighost", \%customhost); &General::readhasharray("$configccdnet", \%ccdnet); &General::readhasharray("$configccdhost", \%ccdhost); + &General::readhasharray("$fwconfigfwd", \%fwfwd); + &General::readhasharray("$fwconfiginp", \%fwinp); + &General::readhasharray("$fwconfigout", \%fwout); + &General::readhasharray("$configgrp", \%customgrp); if (!keys %customhost) { print "
$Lang::tr{'fwhost empty'}"; }else{ print< -
+
$Lang::tr{'name'}$Lang::tr{'fwhost netaddress'}$Lang::tr{'remark'}$Lang::tr{'used'}
$customnetwork{$key}[0]
".&Header::colorize($colnet)."$customnetwork{$key}[3]$customnetwork{$key}[4]x$customnetwork{$key}[0]".&Header::colorize($colnet)."$customnetwork{$key}[3]$netcount x @@ -1481,11 +1496,11 @@ END
$Lang::tr{'name'}$Lang::tr{'fwhost ip_mac'}$Lang::tr{'remark'}$Lang::tr{'used'}
+ END } my $count=0; + my $col=''; foreach my $key (sort { ncmp ($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) { if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) { - print" "; - }elsif ($count % 2){ print" ";} - else{ print" ";} + print" "; + $col="bgcolor='${Header::colouryellow}'"; + }elsif ($count % 2){ + print" "; + $col="bgcolor='$color{'color20'}'"; + }else{ + $col="bgcolor='$color{'color22'}'"; + print" "; + } my ($ip,$sub)=split(/\//,$customhost{$key}[2]); $customhost{$key}[4]=~s/\s+//g; - print""; + my $hostcount=0; + $hostcount=&gethostcount($customhost{$key}[0]); + print""; print<
+
END - if($customhost{$key}[4] == '0') + if($hostcount == '0') { - print""; + print""; }else{ - print""; + print""; } $count++; } @@ -1598,6 +1626,9 @@ sub viewtablegrp &General::readhasharray("$configccdnet", \%ccdnet); &General::readhasharray("$confighost", \%customhost); &General::readhasharray("$confignet", \%customnetwork); + &General::readhasharray("$fwconfigfwd", \%fwfwd); + &General::readhasharray("$fwconfiginp", \%fwinp); + &General::readhasharray("$fwconfigout", \%fwout); my @grp=(); my $helper=''; my $count=1; @@ -1606,7 +1637,7 @@ sub viewtablegrp my $number; my $delflag; if (!keys %customgrp) - { + { print "
$Lang::tr{'fwhost err emptytable'}"; }else{ foreach my $key (sort { ncmp($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){ @@ -1629,38 +1660,45 @@ sub viewtablegrp if($count gt 1){ print"
$Lang::tr{'name'}$Lang::tr{'fwhost ip_mac'}$Lang::tr{'remark'}$Lang::tr{'used'}
$customhost{$key}[0]".&Header::colorize($ip)."$customhost{$key}[3]$customhost{$key}[4]x$customhost{$key}[0]".&Header::colorize($ip)."$customhost{$key}[3]$hostcount x @@ -1576,11 +1604,11 @@ END
";} print "
$grpname   "; print " $Lang::tr{'remark'}:  $remark   " if ($remark ne ''); - print "$Lang::tr{'used'}: $customgrp{$key}[4]x"; - if($customgrp{$key}[4] == '0') + my $netgrpcount=&getnetcount($grpname); + print "$Lang::tr{'used'}: $netgrpcount x"; + if($netgrpcount == '0') { print"
"; } print"
"; - print""; + print"
Name$Lang::tr{'ip address'}$Lang::tr{'fwhost type'}
"; } - + my $col=''; if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) { - print" "; + print" "; + $col="bgcolor='${Header::colouryellow}'"; }elsif ($count %2 == 0){ - print""; + print""; + $col="bgcolor='$color{'color22'}'"; }else{ - print""; + print""; + $col="bgcolor='$color{'color20'}'"; } my $ip=&getipforgroup($customgrp{$key}[2],$customgrp{$key}[3]); - if ($ip eq ''){print"";} - print ""; + $col="bgcolor='${Header::colouryellow}'"; + } + print ""; }else{ print "$customgrp{$key}[2]"; } if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr{'fwhost err emptytable'}){ - print ""; @@ -1687,25 +1725,33 @@ sub viewtableservice &General::readhasharray("$fwconfiginp", \%fwinp); &General::readhasharray("$fwconfigout", \%fwout); print< - +
Name$Lang::tr{'ip address'}$Lang::tr{'fwhost type'}
"; + if ($ip eq ''){ + print"
"; if($customgrp{$key}[3] eq 'Standard Network'){ print &get_name($customgrp{$key}[2])."$Lang::tr{'fwhost deleted'}$customgrp{$key}[3]
"; + print "
$Lang::tr{'fwhost deleted'}$customgrp{$key}[3]"; }else{ my ($colip,$colsub) = split("/",$ip); $ip="$colip/".&General::subtocidr($colsub) if ($colsub); - print"".&Header::colorize($ip)."$customgrp{$key}[3]"; + print"".&Header::colorize($ip)."$customgrp{$key}[3]"; } - if ($delflag > '1' && $ip ne ''){ + if ($delflag > 1 && $ip ne ''){ print""; } print"
$Lang::tr{'fwhost srv_name'}$Lang::tr{'fwhost prot'}$Lang::tr{'fwhost port'}ICMP$Lang::tr{'fwhost used'}
+ END + my $col=''; foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0])} keys %customservice) { $count++; if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) { - print" "; - }elsif ($count % 2){ print" ";}else{ print" ";} + print" "; + $col="bgcolor='${Header::colouryellow}'"; + }elsif ($count % 2){ + print" "; + $col="bgcolor='$color{'color22'}'"; + }else{ + print" "; + $col="bgcolor='$color{'color20'}'"; + } print<$customservice{$key}[0] - + "; + print""; }else{ - print""; + print""; } } print"
$Lang::tr{'fwhost srv_name'}$Lang::tr{'fwhost prot'}$Lang::tr{'fwhost port'}ICMP$Lang::tr{'fwhost used'}
$customservice{$key}[2]$customservice{$key}[1] + $customservice{$key}[0]$customservice{$key}[2]$customservice{$key}[1] END #Neuer count $srvcount=&getsrvcount($customservice{$key}[0]); if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr{'fwdfw all icmp'};} elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];} print<$srvcount x
+
$srvcount x @@ -1713,9 +1759,9 @@ END END if ($srvcount eq '0') { - print"
"; @@ -1732,6 +1778,7 @@ sub viewtableservicegrp my $protocol; my $delflag; my $grpcount=0; + my $col=''; if (! -z $configsrvgrp){ &Header::openbox('100%', 'left', $Lang::tr{'fwhost cust srvgrp'}); &General::readhasharray("$configsrvgrp", \%customservicegrp); @@ -1771,14 +1818,17 @@ sub viewtableservicegrp print"
"; } print"
"; - print""; + print"
Name$Lang::tr{'port'}$Lang::tr{'fwhost prot'}
"; } if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) { - print" "; + print""; + $col="bgcolor='${Header::colouryellow}'"; }elsif ($count %2 == 0){ - print""; + print""; + $col="bgcolor='$color{'color20'}'"; }else{ - print""; + print""; + $col="bgcolor='$color{'color22'}'"; } #Set fields if we use protocols in servicegroups if ($customservicegrp{$key}[2] ne 'TCP' || $customservicegrp{$key}[2] ne 'UDP' || $customservicegrp{$key}[2] ne 'ICMP'){ @@ -1790,7 +1840,7 @@ sub viewtableservicegrp if ($customservicegrp{$key}[2] eq 'IGMP'){$protocol='IGMP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IGMP";} if ($customservicegrp{$key}[2] eq 'IPIP'){$protocol='IPIP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPIP";} if ($customservicegrp{$key}[2] eq 'IPV6'){$protocol='IPV6';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPv6 encapsulation";} - print ""; + print ""; foreach my $srv (sort keys %customservice){ if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){ $protocol=$customservice{$srv}[2]; @@ -1798,7 +1848,7 @@ sub viewtableservicegrp last; } } - print"
Name$Lang::tr{'port'}$Lang::tr{'fwhost prot'}
$customservicegrp{$key}[2]$customservicegrp{$key}[2]$port$protocol
"; + print"
$port$protocol"; if ($delflag gt '1'){ print""; } @@ -1903,6 +1953,33 @@ sub checkservicegroup } return $errormessage; } +sub checkrulereload +{ + my $search=shift; + &General::readhasharray("$fwconfigfwd", \%fwfwd); + &General::readhasharray("$fwconfiginp", \%fwinp); + &General::readhasharray("$fwconfigout", \%fwout); + + #check if service or servicegroup is used in rules + foreach my $key (keys %fwfwd){ + if($search eq $fwfwd{$key}[15]){ + &General::firewall_config_changed(); + return; + } + } + foreach my $key (keys %fwinp){ + if($search eq $fwinp{$key}[15]){ + &General::firewall_config_changed(); + return; + } + } + foreach my $key (keys %fwout){ + if($search eq $fwout{$key}[15]){ + &General::firewall_config_changed(); + return; + } + } +} sub error { if ($errormessage) { @@ -1930,6 +2007,84 @@ sub get_name return "$network" if ($val eq $defaultNetworks{$network}{'NAME'}); } } +sub gethostcount +{ + my $searchstring=shift; + my $srvcounter=0; + #Count services used in servicegroups + foreach my $key (keys %customgrp) { + if($customgrp{$key}[2] eq $searchstring){ + $srvcounter++; + } + } + #Count services used in firewall - config + foreach my $key1 (keys %fwfwd) { + if($fwfwd{$key1}[4] eq $searchstring){ + $srvcounter++; + } + if($fwfwd{$key1}[6] eq $searchstring){ + $srvcounter++; + } + } + #Count services used in firewall - input + foreach my $key2 (keys %fwinp) { + if($fwinp{$key2}[4] eq $searchstring){ + $srvcounter++; + } + if($fwinp{$key2}[6] eq $searchstring){ + $srvcounter++; + } + } + #Count services used in firewall - outgoing + foreach my $key3 (keys %fwout) { + if($fwout{$key3}[4] eq $searchstring){ + $srvcounter++; + } + if($fwout{$key3}[6] eq $searchstring){ + $srvcounter++; + } + } + return $srvcounter; +} +sub getnetcount +{ + my $searchstring=shift; + my $srvcounter=0; + #Count services used in servicegroups + foreach my $key (keys %customgrp) { + if($customgrp{$key}[2] eq $searchstring){ + $srvcounter++; + } + } + #Count services used in firewall - config + foreach my $key1 (keys %fwfwd) { + if($fwfwd{$key1}[4] eq $searchstring){ + $srvcounter++; + } + if($fwfwd{$key1}[6] eq $searchstring){ + $srvcounter++; + } + } + #Count services used in firewall - input + foreach my $key2 (keys %fwinp) { + if($fwinp{$key2}[4] eq $searchstring){ + $srvcounter++; + } + if($fwinp{$key2}[6] eq $searchstring){ + $srvcounter++; + } + } + #Count services used in firewall - outgoing + foreach my $key3 (keys %fwout) { + if($fwout{$key3}[4] eq $searchstring){ + $srvcounter++; + } + if($fwout{$key3}[6] eq $searchstring){ + $srvcounter++; + } + } + return $srvcounter; +} sub getsrvcount { my $searchstring=shift; @@ -2218,6 +2373,36 @@ sub decreaseservice &General::writehasharray("$configsrv", \%customservice); } +sub changenameinfw +{ + my $old=shift; + my $new=shift; + my $fld=shift; + &General::readhasharray("$fwconfigfwd", \%fwfwd); + &General::readhasharray("$fwconfiginp", \%fwinp); + &General::readhasharray("$fwconfigout", \%fwout); + #Rename group in Firewall-CONFIG + foreach my $key1 (keys %fwfwd) { + if($fwfwd{$key1}[$fld] eq $old){ + $fwfwd{$key1}[$fld]=$new; + } + } + &General::writehasharray("$fwconfigfwd", \%fwfwd ); + #Rename group in Firewall-INPUT + foreach my $key2 (keys %fwinp) { + if($fwinp{$key2}[$fld] eq $old){ + $fwinp{$key2}[$fld]=$new; + } + } + &General::writehasharray("$fwconfiginp", \%fwinp ); + #Rename group in Firewall-OUTGOING + foreach my $key3 (keys %fwout) { + if($fwout{$key3}[$fld] eq $old){ + $fwout{$key3}[$fld]=$new; + } + } + &General::writehasharray("$fwconfigout", \%fwout ); +} sub checkports {