line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Exim::ACL::Geolocation; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
86377
|
use 5.016; |
|
1
|
|
|
|
|
10
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
7
|
1
|
|
|
1
|
|
5
|
use utf8; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 1.002; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
45
|
use Exporter qw(import); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
12
|
1
|
|
|
1
|
|
383
|
use IP::Geolocation::MMDB; |
|
1
|
|
|
|
|
43933
|
|
|
1
|
|
|
|
|
33
|
|
13
|
1
|
|
|
1
|
|
6
|
use List::Util qw(first); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
244
|
|
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
|
|
|
|
|
|
|
GeoIP2-Country.mmdb |
24
|
|
|
|
|
|
|
GeoIP2-City.mmdb |
25
|
|
|
|
|
|
|
dbip-country.mmdb |
26
|
|
|
|
|
|
|
dbip-location.mmdb |
27
|
|
|
|
|
|
|
GeoLite2-Country.mmdb |
28
|
|
|
|
|
|
|
GeoLite2-City.mmdb |
29
|
|
|
|
|
|
|
dbip-country-lite.mmdb |
30
|
|
|
|
|
|
|
dbip-city-lite.mmdb |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our $DATABASE = $ENV{IP_GEOLOCATION_MMDB} || first {-r} map { |
34
|
|
|
|
|
|
|
my $dir = $_; |
35
|
|
|
|
|
|
|
map {"$dir/$_"} @DATABASES |
36
|
|
|
|
|
|
|
} @DIRECTORIES; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
our $MMDB = eval { IP::Geolocation::MMDB->new(file => $DATABASE) }; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub country_code { |
41
|
2
|
|
|
2
|
1
|
1482
|
my $ip_address = shift; |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
5
|
return eval { $MMDB->getcc($ip_address) }; |
|
2
|
|
|
|
|
8
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
__END__ |