line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MaxMind::DB::Reader::Role::Reader; |
2
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
12467
|
use strict; |
|
21
|
|
|
|
|
30
|
|
|
21
|
|
|
|
|
598
|
|
4
|
21
|
|
|
21
|
|
78
|
use warnings; |
|
21
|
|
|
|
|
24
|
|
|
21
|
|
|
|
|
552
|
|
5
|
21
|
|
|
21
|
|
74
|
use namespace::autoclean; |
|
21
|
|
|
|
|
30
|
|
|
21
|
|
|
|
|
129
|
|
6
|
21
|
|
|
21
|
|
4354
|
use autodie; |
|
21
|
|
|
|
|
31
|
|
|
21
|
|
|
|
|
135
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.000012'; |
9
|
|
|
|
|
|
|
|
10
|
21
|
|
|
21
|
|
80823
|
use Data::Validate::IP 0.25 qw( is_ip ); |
|
21
|
|
|
|
|
594118
|
|
|
21
|
|
|
|
|
2083
|
|
11
|
21
|
|
|
21
|
|
172
|
use MaxMind::DB::Types qw( Str ); |
|
21
|
|
|
|
|
33
|
|
|
21
|
|
|
|
|
876
|
|
12
|
|
|
|
|
|
|
|
13
|
21
|
|
|
21
|
|
99
|
use Moo::Role; |
|
21
|
|
|
|
|
32
|
|
|
21
|
|
|
|
|
220
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
requires qw( |
16
|
|
|
|
|
|
|
_build_metadata |
17
|
|
|
|
|
|
|
_data_for_address |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
21
|
|
|
21
|
|
9573
|
use constant DEBUG => $ENV{MAXMIND_DB_READER_DEBUG}; |
|
21
|
|
|
|
|
35
|
|
|
21
|
|
|
|
|
5852
|
|
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
|
174504
|
my $self = shift; |
31
|
209
|
|
|
|
|
338
|
my $addr = shift; |
32
|
|
|
|
|
|
|
|
33
|
209
|
100
|
66
|
|
|
1395
|
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
|
|
|
|
901
|
die |
40
|
|
|
|
|
|
|
"The IP address you provided ($addr) is not a valid IPv4 or IPv6 address" |
41
|
|
|
|
|
|
|
unless is_ip($addr); |
42
|
|
|
|
|
|
|
|
43
|
203
|
|
|
|
|
4263
|
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; |