line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IP::Geolocation::MMDB; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
147655
|
use 5.016; |
|
1
|
|
|
|
|
9
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
7
|
1
|
|
|
1
|
|
5
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 1.008; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
434
|
use IP::Geolocation::MMDB::Metadata; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
12
|
1
|
|
|
1
|
|
908
|
use Math::BigInt 1.999806; |
|
1
|
|
|
|
|
20797
|
|
|
1
|
|
|
|
|
5
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
require XSLoader; |
15
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
3
|
|
|
3
|
1
|
850
|
my ($class, %attrs) = @_; |
19
|
|
|
|
|
|
|
|
20
|
3
|
100
|
|
|
|
21
|
my $file = $attrs{file} or die q{The "file" parameter is mandatory}; |
21
|
2
|
|
|
|
|
4
|
my $flags = 0; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
123
|
my $self = $class->_new($file, $flags); |
24
|
1
|
|
|
|
|
4
|
bless $self, $class; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
5
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub getcc { |
30
|
2
|
|
|
2
|
1
|
1845
|
my ($self, $ip_address) = @_; |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
4
|
my $country_code; |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
|
|
80
|
my $data = $self->record_for_address($ip_address); |
35
|
2
|
50
|
|
|
|
1095
|
if (ref $data eq 'HASH') { |
36
|
2
|
50
|
|
|
|
6
|
if (exists $data->{country}) { |
37
|
2
|
|
|
|
|
4
|
my $country = $data->{country}; |
38
|
2
|
50
|
|
|
|
6
|
if (exists $country->{iso_code}) { |
39
|
2
|
|
|
|
|
4
|
$country_code = $country->{iso_code}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
25
|
return $country_code; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub metadata { |
48
|
1
|
|
|
1
|
1
|
6338
|
my ($self) = @_; |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
3
|
return IP::Geolocation::MMDB::Metadata->new(%{$self->_metadata}); |
|
1
|
|
|
|
|
35
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _to_bigint { |
56
|
14
|
|
|
14
|
|
8639
|
my ($self, $bytes) = @_; |
57
|
|
|
|
|
|
|
|
58
|
14
|
|
|
|
|
48
|
return Math::BigInt->from_bytes($bytes); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
__END__ |