blib/lib/OpenDNS/MyIP.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 50 CC 3 SCAR 15.5
CC
3
Cov
0%
get_ip
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 4.7
1 package OpenDNS::MyIP;
2 # ABSTRACT: Get your public IP address
3 $OpenDNS::MyIP::VERSION = '1.250650';
4 use 5.006;
5 use strict;
6 use warnings;
7  
8 use Net::DNS;
9 use Carp;
10  
11 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
12  
13 require Exporter;
14 require AutoLoader;
15  
16 our @ISA = qw(Exporter AutoLoader);
17 our @EXPORT = qw(get_ip);
18  
19 sub get_ip{
20 my $resolver = new Net::DNS::Resolver(
21 nameservers => [ '208.67.220.220', '208.67.222.222' ],
22 recurse => 0,
23 debug => 0
24 );
25  
26 my $query = $resolver->query( 'myip.opendns.com' );
27  
28 if ($query) {
29 foreach my $rr ($query->answer) {
30 next unless $rr->type eq "A";
31 return $rr->rdstring();
32 }
33 } else {
34 confess($resolver->errorstring);
35 }
36 }
37  
38 1;
39  
40 =pod
41  
42 =encoding UTF-8
43  
44 =head1 NAME
45  
46 OpenDNS::MyIP - Get your public IP address
47  
48 =head1 VERSION
49  
50 version 1.250650
51  
52 =head1 SYNOPSIS
53  
54 use OpenDNS::MyIP qw(get_ip);
55  
56 my $ip = get_ip(); # 12.34.56.78
57  
58 =head1 METHODS
59  
60 =head2 get_ip()
61  
62 Return public IP address
63  
64 =head1 SEE ALSO
65  
66 L<https://metacpan.org/pod/WWW::IP>
67  
68 L<https://metacpan.org/pod/WWW::curlmyip>
69  
70 L<https://metacpan.org/pod/WWW::ipinfo>
71  
72 L<https://metacpan.org/pod/WWW::hmaip>
73  
74 L<https://metacpan.org/pod/WWW::PerlTricksIP>
75  
76 =head1 AUTHOR
77  
78 Petr Kletecka <pek@cpan.org>
79  
80 =head1 COPYRIGHT AND LICENSE
81  
82 This software is copyright (c) 2015, 2025 by Petr Kletecka.
83  
84 This is free software; you can redistribute it and/or modify it under
85 the same terms as the Perl 5 programming language system itself.
86  
87 =cut
88  
89 __END__