]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
connections.cgi: Use &General::formatBytes() for format usage
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Apr 2024 11:50:31 +0000 (13:50 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 7 Aug 2024 12:27:12 +0000 (14:27 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
html/cgi-bin/connections.cgi

index 055fc3cbcaf51369289e6a312d0988f6e2e15dec..b8a27a28f155f67f79eef3cb7ac3dc9097188c7d 100644 (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;