public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Adolf Belka <adolf.belka@ipfire.org>
To: Michael Tremer <michael.tremer@ipfire.org>,
	dietzmann@brecht-schule.hamburg
Cc: "IPFire: Development-List" <development@lists.ipfire.org>
Subject: Re: [PATCH 1/5] fwhosts.cgi: Show in which firewall rule objects are being used
Date: Wed, 25 Jun 2025 18:25:57 +0200	[thread overview]
Message-ID: <4bb586c6-0db4-410b-95c1-170f367b28e8@ipfire.org> (raw)
In-Reply-To: <20250623171658.530138-1-michael.tremer@ipfire.org>

Tested-by: Adolf Belka <adolf.belka@ipfire.org>

I initially tested the whole of the patch set but then I could not figure out where the firewall rule info was to be found.

Then I tested out only this first patch on its own and saw the i in a blue circle icon and then when I held my mouse over that for a second or so it showed the info.

I like the additional info that has been provided with this. That will be useful to have.

I will do a separate feedback to patch 4/5.


On 23/06/2025 19:16, Michael Tremer wrote:
> From: Peer Dietzmann <dietzmann@brecht-schule.hamburg>
> 
> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
> ---
>   doc/language_issues.en   |   1 +
>   doc/language_issues.es   |   1 +
>   doc/language_issues.fr   |   1 +
>   doc/language_issues.it   |   1 +
>   doc/language_issues.nl   |   1 +
>   doc/language_issues.pl   |   1 +
>   doc/language_issues.ru   |   1 +
>   doc/language_issues.tr   |   1 +
>   doc/language_missings    |   7 +
>   html/cgi-bin/fwhosts.cgi | 368 +++++++++++++++++++++++++++++++++++++--
>   langs/de/cgi-bin/de.pl   |   1 +
>   langs/en/cgi-bin/en.pl   |   1 +
>   12 files changed, 375 insertions(+), 10 deletions(-)
> 
> diff --git a/doc/language_issues.en b/doc/language_issues.en
> index 996572456..7d72fa99b 100644
> --- a/doc/language_issues.en
> +++ b/doc/language_issues.en
> @@ -78,6 +78,7 @@ WARNING: untranslated string: TOS rule = TOS rule
>   WARNING: untranslated string: The class number does not match the specified interface. = The class number does not match the specified interface.
>   WARNING: untranslated string: The destination IP address is invalid. = The destination IP address is invalid.
>   WARNING: untranslated string: The source IP address is invalid. = The source IP address is invalid.
> +WARNING: untranslated string: Unused = Unused
>   WARNING: untranslated string: WakeOnLan = Wake On Lan
>   WARNING: untranslated string: a ca certificate with this name already exists = A CA certificate with this name already exists.
>   WARNING: untranslated string: a connection with this common name already exists = A connection with this common name already exists.
> diff --git a/doc/language_issues.es b/doc/language_issues.es
> index 68836302a..e90acf9d9 100644
> --- a/doc/language_issues.es
> +++ b/doc/language_issues.es
> @@ -980,6 +980,7 @@ WARNING: translation string unused: zoneconf val vlan tag range error
>   WARNING: translation string unused: zoneconf val zoneslave amount error
>   WARNING: untranslated string: Captive ACTIVATE = unknown string
>   WARNING: untranslated string: Captive clients = unknown string
> +WARNING: untranslated string: Unused = Unused
>   WARNING: untranslated string: ca name must only contain characters and spaces = unknown string
>   WARNING: untranslated string: dns servers = DNS Servers
>   WARNING: untranslated string: enable disable client = unknown string
> diff --git a/doc/language_issues.fr b/doc/language_issues.fr
> index 80341a1c3..db91be7fe 100644
> --- a/doc/language_issues.fr
> +++ b/doc/language_issues.fr
> @@ -959,6 +959,7 @@ WARNING: translation string unused: zoneconf val vlan amount assignment error
>   WARNING: translation string unused: zoneconf val vlan tag assignment error
>   WARNING: translation string unused: zoneconf val vlan tag range error
>   WARNING: translation string unused: zoneconf val zoneslave amount error
> +WARNING: untranslated string: Unused = Unused
>   WARNING: untranslated string: allowed subnets = Allowed Subnets
>   WARNING: untranslated string: bypassed = Bypassed
>   WARNING: untranslated string: ca name must only contain characters and spaces = unknown string
> diff --git a/doc/language_issues.it b/doc/language_issues.it
> index 4ec3545ba..facb0c256 100644
> --- a/doc/language_issues.it
> +++ b/doc/language_issues.it
> @@ -932,6 +932,7 @@ WARNING: untranslated string: Captive vouchervalid = Allowed time for this coupo
>   WARNING: untranslated string: Captive wrong type = Uploaded file has wrong filetype
>   WARNING: untranslated string: MTU settings = MTU settings:
>   WARNING: untranslated string: Number of Countries for the pie chart = Number of Countries for the pie chart
> +WARNING: untranslated string: Unused = Unused
>   WARNING: untranslated string: access point name = Access Point Name
>   WARNING: untranslated string: access point name is invalid = Access Point Name is invalid
>   WARNING: untranslated string: access point name is required = Access Point Name is required
> diff --git a/doc/language_issues.nl b/doc/language_issues.nl
> index 56c6dadf6..40710c698 100644
> --- a/doc/language_issues.nl
> +++ b/doc/language_issues.nl
> @@ -932,6 +932,7 @@ WARNING: untranslated string: Captive vouchervalid = Allowed time for this coupo
>   WARNING: untranslated string: Captive wrong type = Uploaded file has wrong filetype
>   WARNING: untranslated string: MTU settings = MTU settings:
>   WARNING: untranslated string: Number of Countries for the pie chart = Number of Countries for the pie chart
> +WARNING: untranslated string: Unused = Unused
>   WARNING: untranslated string: access point name = Access Point Name
>   WARNING: untranslated string: access point name is invalid = Access Point Name is invalid
>   WARNING: untranslated string: access point name is required = Access Point Name is required
> diff --git a/doc/language_issues.pl b/doc/language_issues.pl
> index 6ccb0a497..ef464100c 100644
> --- a/doc/language_issues.pl
> +++ b/doc/language_issues.pl
> @@ -848,6 +848,7 @@ WARNING: untranslated string: MB read = MB read
>   WARNING: untranslated string: MB written = MB written
>   WARNING: untranslated string: MTU settings = MTU settings:
>   WARNING: untranslated string: Number of Countries for the pie chart = Number of Countries for the pie chart
> +WARNING: untranslated string: Unused = Unused
>   WARNING: untranslated string: access point name = Access Point Name
>   WARNING: untranslated string: access point name is invalid = Access Point Name is invalid
>   WARNING: untranslated string: access point name is required = Access Point Name is required
> diff --git a/doc/language_issues.ru b/doc/language_issues.ru
> index 8a689daa7..d4f669b1b 100644
> --- a/doc/language_issues.ru
> +++ b/doc/language_issues.ru
> @@ -843,6 +843,7 @@ WARNING: untranslated string: MB read = MB read
>   WARNING: untranslated string: MB written = MB written
>   WARNING: untranslated string: MTU settings = MTU settings:
>   WARNING: untranslated string: Number of Countries for the pie chart = Number of Countries for the pie chart
> +WARNING: untranslated string: Unused = Unused
>   WARNING: untranslated string: access point name = Access Point Name
>   WARNING: untranslated string: access point name is invalid = Access Point Name is invalid
>   WARNING: untranslated string: access point name is required = Access Point Name is required
> diff --git a/doc/language_issues.tr b/doc/language_issues.tr
> index e79fe1388..f557f9a04 100644
> --- a/doc/language_issues.tr
> +++ b/doc/language_issues.tr
> @@ -925,6 +925,7 @@ WARNING: translation string unused: year-graph
>   WARNING: translation string unused: yearly firewallhits
>   WARNING: untranslated string: Captive clients = unknown string
>   WARNING: untranslated string: Captive delete logo = Delete Logo
> +WARNING: untranslated string: Unused = Unused
>   WARNING: untranslated string: access point name = Access Point Name
>   WARNING: untranslated string: access point name is invalid = Access Point Name is invalid
>   WARNING: untranslated string: access point name is required = Access Point Name is required
> diff --git a/doc/language_missings b/doc/language_missings
> index cd005f45a..8487c8a26 100644
> --- a/doc/language_missings
> +++ b/doc/language_missings
> @@ -128,6 +128,7 @@
>   < dns servers
>   < ids provider eol
>   < online
> +< Unused
>   ############################################################################
>   # Checking cgi-bin translations for language: fr                           #
>   ############################################################################
> @@ -181,6 +182,7 @@
>   < system time
>   < timeformat
>   < total
> +< Unused
>   < upload fcdsl.o
>   < warning
>   < wg
> @@ -720,6 +722,7 @@
>   < unblock all
>   < uncheck all
>   < unlimited
> +< Unused
>   < update ruleset
>   < updxlrtr passive mode
>   < uplink bit rate
> @@ -1356,6 +1359,7 @@
>   < unblock all
>   < uncheck all
>   < unlimited
> +< Unused
>   < update ruleset
>   < updxlrtr passive mode
>   < uplink bit rate
> @@ -2398,6 +2402,7 @@
>   < unblock all
>   < uncheck all
>   < unlimited
> +< Unused
>   < update ruleset
>   < updxlrtr passive mode
>   < updxlrtr sources
> @@ -3486,6 +3491,7 @@
>   < unblock all
>   < uncheck all
>   < unlimited
> +< Unused
>   < update ruleset
>   < updxlrtr passive mode
>   < updxlrtr sources
> @@ -3975,6 +3981,7 @@
>   < traffic stat title
>   < transfers
>   < transport mode does not support vti
> +< Unused
>   < update ruleset
>   < updxlrtr passive mode
>   < user management
> diff --git a/html/cgi-bin/fwhosts.cgi b/html/cgi-bin/fwhosts.cgi
> index e92ef6853..6b4e22159 100644
> --- a/html/cgi-bin/fwhosts.cgi
> +++ b/html/cgi-bin/fwhosts.cgi
> @@ -1932,7 +1932,7 @@ sub viewtablenet
>   		}else{
>   			print<<END;
>   			<table width='100%' cellspacing='0' class='tbl'>
> -			<tr><th align='center'><b>$Lang::tr{'name'}</b></th><th align='center'><b>$Lang::tr{'fwhost netaddress'}</b></th><th align='center'><b>$Lang::tr{'remark'}</b></th><th align='center'><b>$Lang::tr{'used'}</b></th><th></th><th width='3%'></th></tr>
> +			<tr><th align='center'><b>$Lang::tr{'name'}</b></th><th align='center'><b>$Lang::tr{'fwhost netaddress'}</b></th><th align='center'><b>$Lang::tr{'remark'}</b></th><th align='center'><b>$Lang::tr{'used'}</b></th><th></th><th></th><th width='3%'></th></tr>
>   END
>   		}
>   		my $count=0;
> @@ -1952,7 +1952,14 @@ END
>   			}
>   			my $colnet="$customnetwork{$key}[1]/".&General::subtocidr($customnetwork{$key}[2]);
>   			my $netcount=&getnetcount($customnetwork{$key}[0]);
> -			print"<td width='20%' $col><form method='post'>$customnetwork{$key}[0]</td><td width='15%' align='center' $col>".&getcolor($colnet)."</td><td width='40%' $col>$customnetwork{$key}[3]</td><td align='center' $col>$netcount x</td>";
> +			my $netusedin=&getusedin($customnetwork{$key}[0]);
> +			my $htmlparttouse="";
> +			if ($netusedin) {
> +				$htmlparttouse = "<input type='image' align='top' src='/images/info.gif' alt='$netusedin' title='$netusedin'>";
> +			} else {
> +				$htmlparttouse = "<input type='image' align='top' src='/images/info.gif' alt='Unused' title='Unused'>";
> +			}
> +			print"<td width='20%' $col><form method='post'>$customnetwork{$key}[0]</td><td width='15%' align='center' $col>".&getcolor($colnet)."</td><td width='40%' $col>$customnetwork{$key}[3]</td><td align='center' $col>$netcount x</td><td>$htmlparttouse</td>";
>   			print<<END;
>   			<td width='1%' $col><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
>   			<input type='hidden' name='ACTION' value='editnet'>
> @@ -2086,7 +2093,7 @@ sub viewtablehost
>   		}else{
>   		print<<END;
>   		<table width='100%' cellspacing='0' class='tbl'>
> -		<tr><th align='center'><b>$Lang::tr{'name'}</b></th><th align='center'><b>$Lang::tr{'fwhost ip_mac'}</b></th><th align='center'><b>$Lang::tr{'remark'}</b></th><th align='center'><b>$Lang::tr{'used'}</b></th><th></th><th width='3%'></th></tr>
> +		<tr><th align='center'><b>$Lang::tr{'name'}</b></th><th align='center'><b>$Lang::tr{'fwhost ip_mac'}</b></th><th align='center'><b>$Lang::tr{'remark'}</b></th><th align='center'><b>$Lang::tr{'used'}</b></th><th></th><th></th><th width='3%'></th></tr>
>   END
>   	}
>   		my $count=0;
> @@ -2106,7 +2113,14 @@ END
>   			$customhost{$key}[4]=~s/\s+//g;
>   			my $hostcount=0;
>   			$hostcount=&gethostcount($customhost{$key}[0]);
> -			print"<td width='20%' $col>$customhost{$key}[0]</td><td width='20%' align='center' $col >".&getcolor($ip)."</td><td width='50%' align='left' $col>$customhost{$key}[3]</td><td align='center' $col>$hostcount x</td>";
> +			my $hostusedin=&getusedin($customhost{$key}[0]);
> +			my $htmlparttouse="";
> +			if ($hostusedin) {
> +				$htmlparttouse = "<input type='image' align='top' src='/images/info.gif' alt='$hostusedin' title='$hostusedin'>";
> +			} else {
> +				$htmlparttouse = "<input type='image' align='top' src='/images/info.gif' alt='Unused' title='Unused'>";
> +			}
> +			print"<td width='20%' $col>$customhost{$key}[0]</td><td width='20%' align='center' $col >".&getcolor($ip)."</td><td width='50%' align='left' $col>$customhost{$key}[3]</td><td align='center' $col>$hostcount x</td><td>$htmlparttouse</td>";
>   			print<<END;
>   			<td width='1%' $col><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
>   			<input type='hidden' name='ACTION' value='edithost' />
> @@ -2182,7 +2196,13 @@ sub viewtablegrp
>   				print "<br><b><u>$grpname</u></b>&nbsp; &nbsp;";
>   				print " <b>$Lang::tr{'remark'}:</b>&nbsp $remark &nbsp " if ($remark ne '');
>   				my $netgrpcount=&getnetcount($grpname);
> -				print "<b>$Lang::tr{'used'}:</b> $netgrpcount x";
> +				print "<b>$Lang::tr{'used'}:</b> $netgrpcount x ";
> +				my $groupusedin=&getusedin($grpname);
> +				if ($groupusedin) {
> +					print "<input type='image' align='top' src='/images/info.gif' alt='$groupusedin' title='$groupusedin'>";				
> +				} else {
> +					print "<input type='image' align='top' src='/images/info.gif' alt='$Lang::tr{'Unused'}' title='$Lang::tr{'Unused'}'>";
> +				}
>   				if($netgrpcount == '0')
>   				{
>   					print"<form method='post' style='display:inline'><input type='image' src='/images/delete.gif' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' align='right' /><input type='hidden' name='grp_name' value='$grpname' ><input type='hidden' name='ACTION' value='delgrp'></form>";
> @@ -2320,8 +2340,13 @@ sub viewtablelocationgrp
>   
>   			# Get group count.
>   			my $locationgrpcount=&getlocationcount($grpname);
> -			print "<b>$Lang::tr{'used'}:</b> $locationgrpcount x";
> -
> +			my $locationusedin=&getlocusedin($grpname);
> +			print "<b>$Lang::tr{'used'}:</b> $locationgrpcount x ";
> +			if ($locationusedin) {
> +				print "<input type='image' align='top' src='/images/info.gif' alt='$locationusedin' title='$locationusedin'>";				
> +			} else {
> +				print "<input type='image' align='top' src='/images/info.gif' alt='$Lang::tr{'Unused'}' title='$Lang::tr{'Unused'}'>";
> +			}
>   			# Only display delete icon, if the group is not used by a firewall rule.
>   			if($locationgrpcount == '0') {
>   				print"<form method='post' style='display:inline'>\n";
> @@ -2442,7 +2467,7 @@ sub viewtableservice
>   		&General::readhasharray("$fwconfigout", \%fwout);
>   		print<<END;
>   			<table width='100%' cellspacing='0' class='tbl'>
> -			<tr><th align='center'><b>$Lang::tr{'fwhost srv_name'}</b></th><th align='center'><b>$Lang::tr{'fwhost prot'}</b></th><th align='center'><b>$Lang::tr{'fwhost port'}</b></th><th align='center'><b>ICMP</b></th><th align='center'><b>$Lang::tr{'fwhost used'}</b></th><th></th><th width='3%'></th></tr>
> +			<tr><th align='center'><b>$Lang::tr{'fwhost srv_name'}</b></th><th align='center'><b>$Lang::tr{'fwhost prot'}</b></th><th align='center'><b>$Lang::tr{'fwhost port'}</b></th><th align='center'><b>ICMP</b></th><th align='center'><b>$Lang::tr{'fwhost used'}</b></th><th></th><th></th><th width='3%'></th></tr>
>   END
>   		my $col='';
>   		foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
> @@ -2463,10 +2488,17 @@ END
>   END
>   			#Neuer count
>   			$srvcount=&getsrvcount($customservice{$key}[0]);
> +			my $serviceusedin=&getsrvusedin($customservice{$key}[0]);
> +			my $htmlparttouse="";
> +			if ($serviceusedin) {
> +				$htmlparttouse="<input type='image' align='top' src='/images/info.gif' alt='$serviceusedin' title='$serviceusedin'>";
> +			} else {
> +				$htmlparttouse="<input type='image' align='top' src='/images/info.gif' alt='$Lang::tr{'Unused'}' title='$Lang::tr{'Unused'}'>";
> +			}
>   			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<<END;
> -			</td><td align='center' $col>$srvcount x</td>
> +			</td><td align='center' $col>$srvcount x</td><td>$htmlparttouse</td>
>   			<td width='1%' $col><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' /><input type='hidden' name='ACTION' value='editservice' />
>   			<input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
>   			<input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
> @@ -2538,7 +2570,13 @@ sub viewtableservicegrp
>   				if($count >0){print"</table>";$count=1;}
>   				print "<br><b><u>$grpname</u></b>&nbsp; &nbsp; ";
>   				print "<b>$Lang::tr{'remark'}:</b>&nbsp; $remark " if ($remark ne '');
> -				print "&nbsp; <b>$Lang::tr{'used'}:</b> $grpcount x";
> +				print "&nbsp; <b>$Lang::tr{'used'}:</b> $grpcount x ";
> +				my $srvgrpusedin=&getsrvusedin($customservicegrp{$key}[0]);
> +				if ($srvgrpusedin) {
> +					print "<input type='image' align='top' src='/images/info.gif' alt='$srvgrpusedin' title='$srvgrpusedin'>";				
> +				} else {
> +					print "<input type='image' align='top' src='/images/info.gif' alt='$Lang::tr{'Unused'}' title='$Lang::tr{'Unused'}'>";
> +				}
>   				if($grpcount == '0')
>   				{
>   					print"<form method='post' style='display:inline'><input type='image' src='/images/delete.gif' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' align='right' /><input type='hidden' name='SRVGRP_NAME' value='$grpname' ><input type='hidden' name='ACTION' value='delservicegrp'></form>";
> @@ -2811,6 +2849,106 @@ sub getlocationcount
>   	}
>   	return $counter;
>   }
> +sub getlocusedin
> +{
> +	my $groupname=shift;
> +	my $titletext="";
> +
> +	# Location groups are stored as "group:groupname" in the
> +	# firewall settings files.
> +	my $searchstring = join(':', "group",$groupname);
> +
> +	#Count services used in firewall - config
> +	my $fwfwtext="";
> +	# first set title if found
> +	foreach my $key1 (keys %fwfwd) {
> +		if($fwfwd{$key1}[4] eq $searchstring){
> +			$fwfwtext = "$Lang::tr{'firewall rules'}:";
> +		}
> +		if($fwfwd{$key1}[6] eq $searchstring){
> +			$fwfwtext = "$Lang::tr{'firewall rules'}:";
> +		}
> +	}
> +	# then add rule numbers
> +	my @fwfwrules = ();
> +	foreach my $key1 (keys %fwfwd) {
> +		if($fwfwd{$key1}[4] eq $searchstring){
> +			push(@fwfwrules, $key1);
> +		}
> +		if($fwfwd{$key1}[6] eq $searchstring){
> +			push(@fwfwrules, $key1);
> +		}
> +	}
> +	my @fwfwarraysorted = sort { $a <=> $b } @fwfwrules;
> +	foreach my $rule (@fwfwarraysorted)
> +	{
> +    	$fwfwtext .= "&#010- $rule";
> +	}
> +	#Count services used in firewall - input
> +	my $fwintext="";
> +	foreach my $key2 (keys %fwinp) {
> +		if($fwinp{$key2}[4] eq $searchstring){
> +			$fwintext = "$Lang::tr{'incoming firewall access'}:";
> +		}
> +		if($fwinp{$key2}[6] eq $searchstring){
> +			$fwintext = "$Lang::tr{'incoming firewall access'}:";
> +		}
> +	}
> +	my @fwinrules = ();
> +	foreach my $key2 (keys %fwinp) {
> +		if($fwinp{$key2}[4] eq $searchstring){
> +			push(@fwinrules, $key2);
> +		}
> +		if($fwinp{$key2}[6] eq $searchstring){
> +			push(@fwinrules, $key2);
> +		}
> +	}
> +	my @fwinarraysorted = sort { $a <=> $b } @fwinrules;
> +	foreach my $rule (@fwinarraysorted)
> +	{
> +    	$fwintext .= "&#010- $rule";
> +	}
> +	#Count services used in firewall - outgoing
> +	my $fwouttext="";
> +	foreach my $key3 (keys %fwout) {
> +		if($fwout{$key3}[4] eq $searchstring){
> +			$fwouttext = "$Lang::tr{'outgoing firewall access'}:";
> +		}
> +		if($fwout{$key3}[6] eq $searchstring){
> +			$fwouttext = "$Lang::tr{'outgoing firewall access'}:";
> +		}
> +	}
> +	my @fwoutrules = ();
> +	foreach my $key3 (keys %fwout) {
> +		if($fwout{$key3}[4] eq $searchstring){
> +			push(@fwoutrules, $key3);
> +		}
> +		if($fwout{$key3}[6] eq $searchstring){
> +			push(@fwoutrules, $key3);
> +		}
> +	}
> +	my @fwoutarraysorted = sort { $a <=> $b } @fwoutrules;
> +	foreach my $rule (@fwoutarraysorted)
> +	{
> +    	$fwouttext .= "&#010- $rule";
> +	}
> +	if ($fwfwtext) {
> +		$titletext .= "$fwfwtext"
> +	}
> +	if ($fwintext) {
> +		if ($titletext) {
> +			$titletext .= "&#010 "
> +		}
> +		$titletext .= "$fwintext"
> +	}
> +	if ($fwouttext) {
> +		if ($titletext) {
> +			$titletext .= "&#010 "
> +		}
> +		$titletext .= "$fwouttext"
> +	}
> +	return $titletext;
> +}
>   sub getnetcount
>   {
>   	my $searchstring=shift;
> @@ -2850,6 +2988,122 @@ sub getnetcount
>   	}
>   	return $srvcounter;
>   }
> +sub getusedin
> +{
> +	my $searchstring=shift;
> +	my $titletext="";
> +	my $groups=();
> +	my $rules=();
> +
> +	#Count services used in Network/Host group
> +	my $servicegrouptext="";
> +	foreach my $key (keys %customgrp) {
> +		if($customgrp{$key}[2] eq $searchstring){
> +			$servicegrouptext = "$Lang::tr{'fwhost cust grp'}:";
> +		}
> +	}
> +	foreach my $key (keys %customgrp) {
> +		if($customgrp{$key}[2] eq $searchstring){
> +			$servicegrouptext .= "&#010- $customgrp{$key}[0]";
> +		}
> +	}
> +	#Count services used in firewall - config
> +	my $fwfwtext="";
> +	# first set title if found
> +	foreach my $key1 (keys %fwfwd) {
> +		if($fwfwd{$key1}[4] eq $searchstring){
> +			$fwfwtext = "$Lang::tr{'firewall rules'}:";
> +		}
> +		if($fwfwd{$key1}[6] eq $searchstring){
> +			$fwfwtext = "$Lang::tr{'firewall rules'}:";
> +		}
> +	}
> +	# then add rule numbers
> +	my @fwfwrules = ();
> +	foreach my $key1 (keys %fwfwd) {
> +		if($fwfwd{$key1}[4] eq $searchstring){
> +			push(@fwfwrules, $key1);
> +		}
> +		if($fwfwd{$key1}[6] eq $searchstring){
> +			push(@fwfwrules, $key1);
> +		}
> +	}
> +	my @fwfwarraysorted = sort { $a <=> $b } @fwfwrules;
> +	foreach my $rule (@fwfwarraysorted)
> +	{
> +    	$fwfwtext .= "&#010- $rule";
> +	}
> +	#Count services used in firewall - input
> +	my $fwintext="";
> +	foreach my $key2 (keys %fwinp) {
> +		if($fwinp{$key2}[4] eq $searchstring){
> +			$fwintext = "$Lang::tr{'incoming firewall access'}:";
> +		}
> +		if($fwinp{$key2}[6] eq $searchstring){
> +			$fwintext = "$Lang::tr{'incoming firewall access'}:";
> +		}
> +	}
> +	my @fwinrules = ();
> +	foreach my $key2 (keys %fwinp) {
> +		if($fwinp{$key2}[4] eq $searchstring){
> +			push(@fwinrules, $key2);
> +		}
> +		if($fwinp{$key2}[6] eq $searchstring){
> +			push(@fwinrules, $key2);
> +		}
> +	}
> +	my @fwinarraysorted = sort { $a <=> $b } @fwinrules;
> +	foreach my $rule (@fwinarraysorted)
> +	{
> +    	$fwintext .= "&#010- $rule";
> +	}
> +	#Count services used in firewall - outgoing
> +	my $fwouttext="";
> +	foreach my $key3 (keys %fwout) {
> +		if($fwout{$key3}[4] eq $searchstring){
> +			$fwouttext = "$Lang::tr{'outgoing firewall access'}:";
> +		}
> +		if($fwout{$key3}[6] eq $searchstring){
> +			$fwouttext = "$Lang::tr{'outgoing firewall access'}:";
> +		}
> +	}
> +	my @fwoutrules = ();
> +	foreach my $key3 (keys %fwout) {
> +		if($fwout{$key3}[4] eq $searchstring){
> +			push(@fwoutrules, $key3);
> +		}
> +		if($fwout{$key3}[6] eq $searchstring){
> +			push(@fwoutrules, $key3);
> +		}
> +	}
> +	my @fwoutarraysorted = sort { $a <=> $b } @fwoutrules;
> +	foreach my $rule (@fwoutarraysorted)
> +	{
> +    	$fwouttext .= "&#010- $rule";
> +	}
> +	if ($servicegrouptext) {
> +		$titletext .= "$servicegrouptext"
> +	}
> +	if ($fwfwtext) {
> +		if ($titletext) {
> +			$titletext .= "&#010 "
> +		}
> +		$titletext .= "$fwfwtext"
> +	}
> +	if ($fwintext) {
> +		if ($titletext) {
> +			$titletext .= "&#010 "
> +		}
> +		$titletext .= "$fwintext"
> +	}
> +	if ($fwouttext) {
> +		if ($titletext) {
> +			$titletext .= "&#010 "
> +		}
> +		$titletext .= "$fwouttext"
> +	}
> +	return $titletext
> +}
>   sub getsrvcount
>   {
>   	my $searchstring=shift;
> @@ -2880,6 +3134,100 @@ sub getsrvcount
>   	}
>   	return $srvcounter;
>   }
> +sub getsrvusedin
> +{
> +	my $searchstring=shift;
> +	my $titletext="";
> +	#Count services used in servicegroups
> +	my $servicegrouptext="";
> +	foreach my $key (keys %customservicegrp) {
> +		if($customservicegrp{$key}[2] eq $searchstring){
> +			$servicegrouptext = "$Lang::tr{'outgoing firewall access'}:";
> +		}
> +	}
> +	foreach my $key (keys %customservicegrp) {
> +		if($customservicegrp{$key}[2] eq $searchstring){
> +			$servicegrouptext .= "&#010- $customservicegrp{$key}[0]";
> +		}
> +	}
> +	my $fwfwtext="";
> +	# first set title if found
> +	foreach my $key1 (keys %fwfwd) {
> +		if($fwfwd{$key1}[15] eq $searchstring){
> +			$fwfwtext = "$Lang::tr{'firewall rules'}:";
> +		}
> +	}
> +	# then add rule numbers
> +	my @fwfwrules = ();
> +	foreach my $key1 (keys %fwfwd) {
> +		if($fwfwd{$key1}[15] eq $searchstring){
> +			push(@fwfwrules, $key1);
> +		}
> +	}
> +	my @fwfwarraysorted = sort { $a <=> $b } @fwfwrules;
> +	foreach my $rule (@fwfwarraysorted)
> +	{
> +    	$fwfwtext .= "&#010- $rule";
> +	}
> +	#Count services used in firewall - input
> +	my $fwintext="";
> +	foreach my $key2 (keys %fwinp) {
> +		if($fwinp{$key2}[15] eq $searchstring){
> +			$fwintext = "$Lang::tr{'incoming firewall access'}:";
> +		}
> +	}
> +	my @fwinrules = ();
> +	foreach my $key2 (keys %fwinp) {
> +		if($fwinp{$key2}[15] eq $searchstring){
> +			push(@fwinrules, $key2);
> +		}
> +	}
> +	my @fwinarraysorted = sort { $a <=> $b } @fwinrules;
> +	foreach my $rule (@fwinarraysorted)
> +	{
> +    	$fwintext .= "&#010- $rule";
> +	}
> +	#Count services used in firewall - outgoing
> +	my $fwouttext="";
> +	foreach my $key3 (keys %fwout) {
> +		if($fwout{$key3}[15] eq $searchstring){
> +			$fwouttext = "$Lang::tr{'outgoing firewall access'}:";
> +		}
> +	}
> +	my @fwoutrules = ();
> +	foreach my $key3 (keys %fwout) {
> +		if($fwout{$key3}[15] eq $searchstring){
> +			push(@fwoutrules, $key3);
> +		}
> +	}
> +	my @fwoutarraysorted = sort { $a <=> $b } @fwoutrules;
> +	foreach my $rule (@fwoutarraysorted)
> +	{
> +    	$fwouttext .= "&#010- $rule";
> +	}
> +	if ($servicegrouptext ne '') {
> +		$titletext .= "$servicegrouptext";
> +	}
> +	if ($fwfwtext ne '') {
> +		if ($titletext) {
> +			$titletext .= "&#010 ";
> +		}
> +		$titletext .= "$fwfwtext";
> +	}
> +	if ($fwintext ne '') {
> +		if ($titletext) {
> +			$titletext .= "&#010 ";
> +		}
> +		$titletext .= "$fwintext";
> +	}
> +	if ($fwouttext) {
> +		if ($titletext ne '') {
> +			$titletext .= "&#010 ";
> +		}
> +		$titletext .= "$fwouttext";
> +	}
> +	return $titletext
> +}
>   sub deletefromgrp
>   {
>   	my $target=shift;
> diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl
> index 53d6903ae..130227910 100644
> --- a/langs/de/cgi-bin/de.pl
> +++ b/langs/de/cgi-bin/de.pl
> @@ -122,6 +122,7 @@
>   'The class number does not match the specified interface.' => 'Die Klassennummer passt nicht zum angegebenen Interface.',
>   'The destination IP address is invalid.' => 'Die Ziel-IP-Adresse ist ungültig.',
>   'The source IP address is invalid.' => 'Die Quell-IP-Adresse ist ungültig.',
> +'Unused' => 'Unbenutzt',
>   'Utilization on' => 'Auslastung auf',
>   'Verbose' => 'Verbose',
>   'WakeOnLan' => 'Wake On LAN',
> diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl
> index ef7d75ce7..e76ca878c 100644
> --- a/langs/en/cgi-bin/en.pl
> +++ b/langs/en/cgi-bin/en.pl
> @@ -120,6 +120,7 @@
>   'The class number does not match the specified interface.' => 'The class number does not match the specified interface.',
>   'The destination IP address is invalid.' => 'The destination IP address is invalid.',
>   'The source IP address is invalid.' => 'The source IP address is invalid.',
> +'Unused' => 'Unused',
>   'Utilization on' => 'Utilization on',
>   'Verbose' => 'Verbose:',
>   'WakeOnLan' => 'Wake On Lan',



      parent reply	other threads:[~2025-06-25 16:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23 17:16 Michael Tremer
2025-06-23 17:16 ` [PATCH 2/5] fwhosts.cgi: Remove whitespace issues Michael Tremer
2025-06-23 17:16 ` [PATCH 3/5] fwhosts.cgi: Don't show anything if a host/group is unused Michael Tremer
2025-06-23 17:16 ` [PATCH 4/5] fwhosts.cgi: Move the tooltip into the usage counter Michael Tremer
2025-06-25 16:40   ` Adolf Belka
2025-06-25 16:52     ` Michael Tremer
2025-06-26 12:08       ` [EXTERN] " Peer Dietzmann
2025-06-26 15:13         ` Adam Gibbons
2025-06-23 17:16 ` [PATCH 5/5] langs: Remove the unused "Unused" translation string Michael Tremer
2025-06-25 16:25 ` Adolf Belka [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4bb586c6-0db4-410b-95c1-170f367b28e8@ipfire.org \
    --to=adolf.belka@ipfire.org \
    --cc=development@lists.ipfire.org \
    --cc=dietzmann@brecht-schule.hamburg \
    --cc=michael.tremer@ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox