line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MaxMind::DB::Reader::Role::Reader; |
2
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
12387
|
use strict; |
|
21
|
|
|
|
|
65
|
|
|
21
|
|
|
|
|
675
|
|
4
|
21
|
|
|
21
|
|
122
|
use warnings; |
|
21
|
|
|
|
|
65
|
|
|
21
|
|
|
|
|
600
|
|
5
|
21
|
|
|
21
|
|
121
|
use namespace::autoclean; |
|
21
|
|
|
|
|
50
|
|
|
21
|
|
|
|
|
156
|
|
6
|
21
|
|
|
21
|
|
1374
|
use autodie; |
|
21
|
|
|
|
|
53
|
|
|
21
|
|
|
|
|
202
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.000014'; |
9
|
|
|
|
|
|
|
|
10
|
21
|
|
|
21
|
|
125352
|
use Data::Validate::IP 0.25 qw( is_ip ); |
|
21
|
|
|
|
|
679984
|
|
|
21
|
|
|
|
|
1946
|
|
11
|
21
|
|
|
21
|
|
197
|
use MaxMind::DB::Types qw( Str ); |
|
21
|
|
|
|
|
56
|
|
|
21
|
|
|
|
|
982
|
|
12
|
|
|
|
|
|
|
|
13
|
21
|
|
|
21
|
|
137
|
use Moo::Role; |
|
21
|
|
|
|
|
56
|
|
|
21
|
|
|
|
|
257
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
requires qw( |
16
|
|
|
|
|
|
|
_build_metadata |
17
|
|
|
|
|
|
|
_data_for_address |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
21
|
|
|
21
|
|
12159
|
use constant DEBUG => $ENV{MAXMIND_DB_READER_DEBUG}; |
|
21
|
|
|
|
|
143
|
|
|
21
|
|
|
|
|
6746
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has file => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
isa => Str, |
25
|
|
|
|
|
|
|
coerce => sub {"$_[0]"}, |
26
|
|
|
|
|
|
|
required => 1, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub record_for_address { |
30
|
209
|
|
|
209
|
0
|
201254
|
my $self = shift; |
31
|
209
|
|
|
|
|
501
|
my $addr = shift; |
32
|
|
|
|
|
|
|
|
33
|
209
|
100
|
66
|
|
|
1360
|
die 'You must provide an IP address to look up' |
34
|
|
|
|
|
|
|
unless defined $addr && length $addr; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# We validate the IP address here as libmaxminddb allows more liberal |
37
|
|
|
|
|
|
|
# numbers and dots notation for IPv4 (e.g., `1.1.1` or `01.1.1.1`) rather |
38
|
|
|
|
|
|
|
# than requiring the standard dotted quad due to using getaddrinfo. |
39
|
208
|
100
|
|
|
|
935
|
die |
40
|
|
|
|
|
|
|
"The IP address you provided ($addr) is not a valid IPv4 or IPv6 address" |
41
|
|
|
|
|
|
|
unless is_ip($addr); |
42
|
|
|
|
|
|
|
|
43
|
203
|
|
|
|
|
7342
|
return $self->_data_for_address($addr); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
around _build_metadata => sub { |
47
|
|
|
|
|
|
|
my $orig = shift; |
48
|
|
|
|
|
|
|
my $self = shift; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return $self->$orig(@_) unless DEBUG; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $metadata = $self->$orig(@_); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$metadata->debug_dump; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return $metadata; |
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |