| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
170537
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
45
|
|
|
2
|
1
|
|
|
1
|
|
15
|
use 5.020; |
|
|
1
|
|
|
|
|
4
|
|
|
3
|
1
|
|
|
1
|
|
421
|
use experimental qw( signatures ); |
|
|
1
|
|
|
|
|
3201
|
|
|
|
1
|
|
|
|
|
5
|
|
|
4
|
1
|
|
|
1
|
|
602
|
use stable qw( postderef ); |
|
|
1
|
|
|
|
|
358
|
|
|
|
1
|
|
|
|
|
4
|
|
|
5
|
1
|
|
|
1
|
|
414
|
use true; |
|
|
1
|
|
|
|
|
6842
|
|
|
|
1
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package WebService::WTFIsMyIP 0.01 { |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Client for wtfismyip.com |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
1135
|
use Ref::Util qw( is_blessed_ref ); |
|
|
1
|
|
|
|
|
1962
|
|
|
|
1
|
|
|
|
|
69
|
|
|
13
|
1
|
|
|
1
|
|
387
|
use JSON::MaybeXS qw( decode_json ); |
|
|
1
|
|
|
|
|
5711
|
|
|
|
1
|
|
|
|
|
119
|
|
|
14
|
|
|
|
|
|
|
use Class::Tiny { |
|
15
|
|
|
|
|
|
|
ua => sub { |
|
16
|
0
|
|
|
|
|
|
require HTTP::Tiny; |
|
17
|
0
|
|
|
|
|
|
return HTTP::Tiny->new; |
|
18
|
|
|
|
|
|
|
}, |
|
19
|
1
|
|
|
|
|
6
|
base_url => "https://wtfismyip.com/", |
|
20
|
1
|
|
|
1
|
|
390
|
}; |
|
|
1
|
|
|
|
|
1674
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
0
|
|
sub BUILD ($self, $) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
unless(is_blessed_ref $self->ua) { |
|
24
|
0
|
|
|
|
|
|
die "ua must be an instance of HTTP::AnyUA or a user agent supported by HTTP::AnyUA"; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
0
|
0
|
|
|
|
|
unless($self->ua->isa("HTTP::AnyUA")) { |
|
27
|
0
|
|
|
|
|
|
require HTTP::AnyUA; |
|
28
|
0
|
|
|
|
|
|
$self->ua(HTTP::AnyUA->new($self->ua)); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
0
|
0
|
|
|
|
unless(is_blessed_ref $self->base_url && $self->base_url->isa("URI")) { |
|
32
|
0
|
|
|
|
|
|
require URI; |
|
33
|
0
|
|
|
|
|
|
$self->base_url(URI->new("@{[ $self->base_url ]}")); |
|
|
0
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
1
|
|
sub json ($self) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $url = $self->base_url->clone; |
|
41
|
0
|
|
|
|
|
|
$url->path("/json"); |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $res = $self->ua->get($url); |
|
44
|
0
|
0
|
|
|
|
|
if($res->{success}) { |
|
45
|
0
|
|
|
|
|
|
my %hash = decode_json($res->{content})->%*; |
|
46
|
0
|
|
|
|
|
|
foreach my $key (keys %hash) { |
|
47
|
0
|
|
|
|
|
|
my $new_key = $key =~ s/^YourFucking//r; |
|
48
|
0
|
0
|
|
|
|
|
$hash{$new_key} = delete $hash{$key} if $key ne $new_key; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
0
|
|
|
|
|
|
return \%hash; |
|
51
|
|
|
|
|
|
|
} else { |
|
52
|
0
|
|
|
|
|
|
die sprintf("%s %s: %s", $res->{status}, $res->{reason}, $url);; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |