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
|
|
85104
|
use 5.016; |
|
1
|
|
|
|
|
14
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
7
|
1
|
|
|
1
|
|
4
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 1.003; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
35
|
use Exporter qw(import); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
12
|
1
|
|
|
1
|
|
383
|
use IP::Geolocation::MMDB; |
|
1
|
|
|
|
|
43848
|
|
|
1
|
|
|
|
|
37
|
|
13
|
1
|
|
|
1
|
|
8
|
use List::Util qw(first); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
257
|
|
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
|
1638
|
my $ip_address = shift; |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
4
|
return eval { $MMDB->getcc($ip_address) }; |
|
2
|
|
|
|
|
8
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
__END__ |