connections.cgi: Use &General::formatBytes() for format usage

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2024-04-27 13:50:31 +02:00
parent 0e8bb539ce
commit 69dcb9bd65

View File

@@ -474,8 +474,9 @@ foreach my $line (<CONNTRACK>) {
$dserv = uc(getservbyport($dport, lc($l4proto)));
}
my $bytes_in = format_bytes($bytes[0]);
my $bytes_out = format_bytes($bytes[1]);
# Format bytes
my $bytes_in = &General::formatBytes($bytes[0]);
my $bytes_out = &General::formatBytes($bytes[1]);
# enumerate location information
my $srcccode = &Location::Functions::lookup_country_code($sip_ret);
@@ -579,21 +580,6 @@ print "</table>";
&Header::closebigbox();
&Header::closepage();
sub format_bytes($) {
my $bytes = shift;
my @units = ("B", "k", "M", "G", "T");
foreach my $unit (@units) {
if ($bytes < 1024) {
return sprintf("%d%s", $bytes, $unit);
}
$bytes /= 1024;
}
return sprintf("%d%s", $bytes, $units[$#units]);
}
sub format_time($) {
my $time = shift;