line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Exim::Blacklist::Geolocation; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
104286
|
use 5.016; |
|
1
|
|
|
|
|
10
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
7
|
1
|
|
|
1
|
|
5
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 1.002; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
62
|
use Exporter qw(import); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
12
|
1
|
|
|
1
|
|
531
|
use IP::Geolocation::MMDB; |
|
1
|
|
|
|
|
690
|
|
|
1
|
|
|
|
|
45
|
|
13
|
1
|
|
|
1
|
|
7
|
use List::Util qw(first); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
291
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT_OK = qw(country_code); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @DIRECTORIES = qw( |
18
|
|
|
|
|
|
|
/var/lib/GeoIP |
19
|
|
|
|
|
|
|
/usr/share/GeoIP |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @DATABASES = qw( |
23
|
|
|
|
|
|
|
dbip-country.mmdb |
24
|
|
|
|
|
|
|
GeoIP2-Country.mmdb |
25
|
|
|
|
|
|
|
dbip-country-lite.mmdb |
26
|
|
|
|
|
|
|
GeoLite2-Country.mmdb |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our $DATABASE = $ENV{GEOIP_COUNTRY} || first {-r} map { |
30
|
|
|
|
|
|
|
my $dir = $_; |
31
|
|
|
|
|
|
|
map {"$dir/$_"} @DATABASES |
32
|
|
|
|
|
|
|
} @DIRECTORIES; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
our $MMDB = eval { IP::Geolocation::MMDB->new(file => $DATABASE) }; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub country_code { |
37
|
2
|
|
|
2
|
1
|
964
|
my $ip_address = shift; |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
|
|
4
|
return eval { $MMDB->getcc($ip_address) }; |
|
2
|
|
|
|
|
7
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
__END__ |