###############################################################################
# #
# IPFire.org - A linux based firewall #
-# Copyright (C) 2007-2012 IPFire Team <info@ipfire.org> #
+# Copyright (C) 2007-2021 IPFire Team <info@ipfire.org> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
###############################################################################
use strict;
+use experimental 'smartmatch';
use Net::IPv4Addr qw( :all );
use Switch;
require '/var/ipfire/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
-require "${General::swroot}/geoip-functions.pl";
+require "${General::swroot}/location-functions.pl";
my $colour_multicast = "#A0A0A0";
($name, $value) = split(/=/, $pair);
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # e.g. "%20" => " "
$value =~ s/[^a-zA-Z0-9]*//g; # a-Z 0-9 will pass
- $cgiin{$name} = $value;
+ $cgiin{$name} = $value;
}
}
}
# Read and sort the connection tracking table
-# do sorting
-if ($SORT_FIELD and $SORT_ORDER) {
+# do sorting
+if ($SORT_FIELD and $SORT_ORDER) {
# field sorting when sorting arguments are sane
open(CONNTRACK, "/usr/local/bin/getconntracktable | /usr/local/bin/consort.sh $SORT_FIELD $SORT_ORDER |") or die "Unable to read conntrack table";
} else {
}
}
+# Call safe system_output function to get all available routes.
+my @all_routes = &General::system_output("/sbin/route", "-n");
+
# Add Green Firewall Interface
push(@network, $netsettings{'GREEN_ADDRESS'});
push(@masklen, "255.255.255.255" );
push(@colour, ${Header::colourfw} );
-# Add Green Network to Array
-push(@network, $netsettings{'GREEN_NETADDRESS'});
-push(@masklen, $netsettings{'GREEN_NETMASK'} );
-push(@colour, ${Header::colourgreen} );
-
-# Add Green Routes to Array
-my @routes = `/sbin/route -n | /bin/grep $netsettings{'GREEN_DEV'}`;
-foreach my $route (@routes) {
- chomp($route);
- my @temp = split(/[\t ]+/, $route);
- push(@network, $temp[0]);
- push(@masklen, $temp[2]);
+if ($netsettings{'GREEN_DEV'}) {
+ # Add Green Network to Array
+ push(@network, $netsettings{'GREEN_NETADDRESS'});
+ push(@masklen, $netsettings{'GREEN_NETMASK'} );
push(@colour, ${Header::colourgreen} );
+
+ # Add Green Routes to Array
+ my @routes = grep (/$netsettings{'GREEN_DEV'}/, @all_routes);
+ foreach my $route (@routes) {
+ chomp($route);
+ my @temp = split(/[\t ]+/, $route);
+ push(@network, $temp[0]);
+ push(@masklen, $temp[2]);
+ push(@colour, ${Header::colourgreen} );
+ }
}
# Add Blue Firewall Interface
push(@colour, ${Header::colourblue} );
# Add Blue Routes to Array
- @routes = `/sbin/route -n | /bin/grep $netsettings{'BLUE_DEV'}`;
+ my @routes = grep(/$netsettings{'BLUE_DEV'}/, @all_routes);
foreach my $route (@routes) {
chomp($route);
my @temp = split(/[\t ]+/, $route);
push(@masklen, $netsettings{'ORANGE_NETMASK'} );
push(@colour, ${Header::colourorange} );
# Add Orange Routes to Array
- @routes = `/sbin/route -n | /bin/grep $netsettings{'ORANGE_DEV'}`;
+ my @routes = grep(/$netsettings{'ORANGE_DEV'}/, @all_routes);
foreach my $route (@routes) {
chomp($route);
my @temp = split(/[\t ]+/, $route);
# Add OpenVPN net for custom OVPNs
if (-e "${General::swroot}/ovpn/ccd.conf") {
- open(OVPNSUB, "${General::swroot}/ovpn/ccd.conf");
+ open(OVPNSUB, "${General::swroot}/ovpn/ccd.conf");
my @ovpnsub = <OVPNSUB>;
close(OVPNSUB);
foreach (@ovpnsub) {
my ($network, $mask) = split '/', (split ',', $_)[2];
-
+
$mask = ipv4_cidr2msk($mask) unless &General::validip($mask);
push(@network, $network);
my $bytes_in = format_bytes($bytes[0]);
my $bytes_out = format_bytes($bytes[1]);
- # enumerate GeoIP information
- my $srcccode = &GeoIP::lookup($sip_ret);
- my $src_flag_icon = &GeoIP::get_flag_icon($srcccode);
- my $dstccode = &GeoIP::lookup($dip_ret);
- my $dst_flag_icon = &GeoIP::get_flag_icon($dstccode);
+ # enumerate location information
+ my $srcccode = &Location::Functions::lookup_country_code($sip_ret);
+ my $src_flag_icon = &Location::Functions::get_flag_icon($srcccode);
+ my $dstccode = &Location::Functions::lookup_country_code($dip_ret);
+ my $dst_flag_icon = &Location::Functions::get_flag_icon($dstccode);
# Format TTL
$ttl = format_time($ttl);