From 50494dfd6ef83f2906cde8e1bd8dbb4992e30aa3 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Fri, 6 Dec 2019 14:30:39 +0100 Subject: [PATCH] logs.cgi/*: Use new location lookup method. Signed-off-by: Stefan Schantl --- html/cgi-bin/logs.cgi/firewalllog.dat | 5 ++++- html/cgi-bin/logs.cgi/firewalllogcountry.dat | 5 ++++- html/cgi-bin/logs.cgi/firewalllogip.dat | 5 ++++- html/cgi-bin/logs.cgi/showrequestfromcountry.dat | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/html/cgi-bin/logs.cgi/firewalllog.dat b/html/cgi-bin/logs.cgi/firewalllog.dat index e67a40a9f5..6d07b62844 100644 --- a/html/cgi-bin/logs.cgi/firewalllog.dat +++ b/html/cgi-bin/logs.cgi/firewalllog.dat @@ -24,6 +24,9 @@ require "${General::swroot}/geoip-functions.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +# Libloc database handle. +my $libloc_db_handle = &GeoIP::init(); + my %color = (); my %mainsettings = (); &General::readhash("${General::swroot}/main/settings", \%mainsettings); @@ -351,7 +354,7 @@ foreach $_ (@log) $srcport=$1 if $packet =~ /SPT=(\d+)/; $dstport=$1 if $packet =~ /DPT=(\d+)/; - my $ccode = &GeoIP::lookup($srcaddr); + my $ccode = &GeoIP::lookup_country_code($libloc_db_handle, $srcaddr); my $servi = uc(getservbyport($srcport, lc($proto))); if ($servi ne '' && $srcport < 1024) { diff --git a/html/cgi-bin/logs.cgi/firewalllogcountry.dat b/html/cgi-bin/logs.cgi/firewalllogcountry.dat index 949f2599da..c241b03205 100644 --- a/html/cgi-bin/logs.cgi/firewalllogcountry.dat +++ b/html/cgi-bin/logs.cgi/firewalllogcountry.dat @@ -22,6 +22,9 @@ require "${General::swroot}/geoip-functions.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +# Libloc database handle. +my $libloc_db_handle = &GeoIP::init(); + use POSIX(); my %cgiparams=(); @@ -308,7 +311,7 @@ foreach $_ (@log) # Traffic from red if($srcaddr ne '') { # srcaddr is set - my $ccode = &GeoIP::lookup($srcaddr); + my $ccode = &GeoIP::lookup_country_code($libloc_db_handle, $srcaddr); if ($ccode eq '') { $ccode = 'unknown'; } diff --git a/html/cgi-bin/logs.cgi/firewalllogip.dat b/html/cgi-bin/logs.cgi/firewalllogip.dat index c73d24fd66..7b117deabe 100644 --- a/html/cgi-bin/logs.cgi/firewalllogip.dat +++ b/html/cgi-bin/logs.cgi/firewalllogip.dat @@ -22,6 +22,9 @@ require "${General::swroot}/geoip-functions.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +# Libloc database handle. +my $libloc_db_handle = &GeoIP::init(); + use POSIX(); my %cgiparams=(); @@ -435,7 +438,7 @@ for($s=0;$s<$lines;$s++) $col="bgcolor='$color{\"color$colorIndex\"}'"; print ""; - my $ccode = &GeoIP::lookup($key[$s]); + my $ccode = &GeoIP::lookup_country_code($libloc_db_handle, $key[$s]); $color++; print "
"; diff --git a/html/cgi-bin/logs.cgi/showrequestfromcountry.dat b/html/cgi-bin/logs.cgi/showrequestfromcountry.dat index 69835370b1..2754830752 100644 --- a/html/cgi-bin/logs.cgi/showrequestfromcountry.dat +++ b/html/cgi-bin/logs.cgi/showrequestfromcountry.dat @@ -19,6 +19,9 @@ require "${General::swroot}/geoip-functions.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +# Libloc database handle. +my $libloc_db_handle = &GeoIP::init(); + use POSIX(); #workaround to suppress a warning when a variable is used only once @@ -178,7 +181,7 @@ if (!$skip) } elsif($srcaddr ne '') { # or srcaddr matches country code - my $ccode = &GeoIP::lookup($srcaddr); + my $ccode = &GeoIP::lookup_country_code($libloc_db_handle, $srcaddr); if($ccode eq uc($country)){ $log[$lines] = $_; $lines++; -- 2.39.5