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
|
|
104369
|
use 5.016; |
|
1
|
|
|
|
|
13
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
7
|
1
|
|
|
1
|
|
5
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 1.004; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
42
|
use Exporter qw(import); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
12
|
1
|
|
|
1
|
|
454
|
use IP::Geolocation::MMDB; |
|
1
|
|
|
|
|
54212
|
|
|
1
|
|
|
|
|
43
|
|
13
|
1
|
|
|
1
|
|
10
|
use List::Util qw(first); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
363
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT_OK = qw(country_code); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @DIRECTORIES = qw( |
18
|
|
|
|
|
|
|
/var/lib/GeoIP |
19
|
|
|
|
|
|
|
/usr/local/share/GeoIP |
20
|
|
|
|
|
|
|
/usr/share/GeoIP |
21
|
|
|
|
|
|
|
/opt/share/GeoIP |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our @DATABASES = qw( |
25
|
|
|
|
|
|
|
GeoIP2-Country.mmdb |
26
|
|
|
|
|
|
|
GeoIP2-City.mmdb |
27
|
|
|
|
|
|
|
dbip-country.mmdb |
28
|
|
|
|
|
|
|
dbip-city.mmdb |
29
|
|
|
|
|
|
|
dbip-location.mmdb |
30
|
|
|
|
|
|
|
GeoLite2-Country.mmdb |
31
|
|
|
|
|
|
|
GeoLite2-City.mmdb |
32
|
|
|
|
|
|
|
dbip-country-lite.mmdb |
33
|
|
|
|
|
|
|
dbip-city-lite.mmdb |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
our $DATABASE = $ENV{IP_GEOLOCATION_MMDB} || first {-r} map { |
37
|
|
|
|
|
|
|
my $dir = $_; |
38
|
|
|
|
|
|
|
map {"$dir/$_"} @DATABASES |
39
|
|
|
|
|
|
|
} @DIRECTORIES; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
our $MMDB = eval { IP::Geolocation::MMDB->new(file => $DATABASE) }; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub country_code { |
44
|
2
|
|
|
2
|
1
|
1794
|
my $ip_address = shift; |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
5
|
return eval { $MMDB->getcc($ip_address) }; |
|
2
|
|
|
|
|
10
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
__END__ |