line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MaxMind::DB::Reader::Role::Reader; |
2
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
9727
|
use strict; |
|
21
|
|
|
|
|
28
|
|
|
21
|
|
|
|
|
508
|
|
4
|
21
|
|
|
21
|
|
66
|
use warnings; |
|
21
|
|
|
|
|
26
|
|
|
21
|
|
|
|
|
404
|
|
5
|
21
|
|
|
21
|
|
67
|
use namespace::autoclean; |
|
21
|
|
|
|
|
20
|
|
|
21
|
|
|
|
|
98
|
|
6
|
21
|
|
|
21
|
|
938
|
use autodie; |
|
21
|
|
|
|
|
25
|
|
|
21
|
|
|
|
|
91
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.000013'; |
9
|
|
|
|
|
|
|
|
10
|
21
|
|
|
21
|
|
70014
|
use Data::Validate::IP 0.25 qw( is_ip ); |
|
21
|
|
|
|
|
480362
|
|
|
21
|
|
|
|
|
1522
|
|
11
|
21
|
|
|
21
|
|
135
|
use MaxMind::DB::Types qw( Str ); |
|
21
|
|
|
|
|
26
|
|
|
21
|
|
|
|
|
764
|
|
12
|
|
|
|
|
|
|
|
13
|
21
|
|
|
21
|
|
81
|
use Moo::Role; |
|
21
|
|
|
|
|
24
|
|
|
21
|
|
|
|
|
189
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
requires qw( |
16
|
|
|
|
|
|
|
_build_metadata |
17
|
|
|
|
|
|
|
_data_for_address |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
21
|
|
|
21
|
|
7808
|
use constant DEBUG => $ENV{MAXMIND_DB_READER_DEBUG}; |
|
21
|
|
|
|
|
27
|
|
|
21
|
|
|
|
|
4908
|
|
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
|
131187
|
my $self = shift; |
31
|
209
|
|
|
|
|
223
|
my $addr = shift; |
32
|
|
|
|
|
|
|
|
33
|
209
|
100
|
66
|
|
|
1035
|
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
|
|
|
|
487
|
die |
40
|
|
|
|
|
|
|
"The IP address you provided ($addr) is not a valid IPv4 or IPv6 address" |
41
|
|
|
|
|
|
|
unless is_ip($addr); |
42
|
|
|
|
|
|
|
|
43
|
203
|
|
|
|
|
4109
|
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; |