| 1 | package Net::Whois::RIS; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | ▶ | use IO::Socket; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 2 | require Exporter; | |||||||||||||||||||
| 8 | 2 | ▶ | use AutoLoader qw(AUTOLOAD); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 2 | our @ISA = qw(Exporter); | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 2 | our %EXPORT_TAGS = ( | |||||||||||||||||||
| 13 | 'all' => [ | ||||||||||||||||||||
| 14 | qw( | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | ) | ||||||||||||||||||||
| 17 | ] | ||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 2 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||
| 21 | 2 | our @EXPORT = qw( ); | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 0 | my ($this) = @_; | |||||||||||||||||||
| 26 | 0 | ▶ | my $class = ref($this) || $this; | ||||||||||||||||||
|
Condition0%0/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table0%0/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||
| 27 | 0 | my $self = {}; | |||||||||||||||||||
| 28 | 0 | bless $self, $class; | |||||||||||||||||||
| 29 | 0 | $self->{host} = "ris.ripe.net"; | |||||||||||||||||||
| 30 | $self->{url} = | ||||||||||||||||||||
| 31 | 0 | "http://www.ris.ripe.net/mt/mas/ajax.mas?_comp=%2Fmt%2Fmas%2Fdashboards.mas%3AgetPrefixesForASN&as=|ASN|&overview_div_graph_id=prefixes_graph_div&martian_warning_div=martian_ov&tabid=1&overview_div_pie_id=prefixes_pie_div&prefixes_graph_img=prefixes_graph_ov&prefixes_pie_img=prefixes_pie_ov%27"; | |||||||||||||||||||
| 32 | 0 | return $self; | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | ▶ | sub getIPInfo { | ||||||||||||||||||
|
Subroutine
getIPInfo: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | my ( $self, $ip ) = @_; | |||||||||||||||||||
| 39 | 0 | ▶ | my $con = IO::Socket::INET->new( PeerAddr => $self->{host}, PeerPort => 43 ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | or die(); | ||||||||||||||||||||
| 41 | 0 | print $con $ip . "\n"; | |||||||||||||||||||
| 42 | 0 | my $x; | |||||||||||||||||||
| 43 | 0 | ▶ | while (<$con>) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | 0 | $x = $x . $_; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | 0 | $con->close; | |||||||||||||||||||
| 47 | 0 | my %h = (); | |||||||||||||||||||
| 48 | 0 | foreach ( split( /\n/, $x ) ) { | |||||||||||||||||||
| 49 | 0 | ▶ | next if (m/^%/); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 50 | 0 | ▶ | next if (m/^$/); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | 0 | my @d = split( /:/, $_ ); | |||||||||||||||||||
| 52 | 0 | $d[1] =~ s/^\s+//; | |||||||||||||||||||
| 53 | 0 | $h{ $d[0] } = $d[1]; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | 0 | $self->{get} = \%h; | |||||||||||||||||||
| 56 | 0 | return $self; | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 0 | ▶ | sub getASNInfo { | ||||||||||||||||||
|
Subroutine
getASNInfo: not called CC=1 SCAR=4.7
Pod
documented
| |||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | my ( $self, $asn ) = @_; | |||||||||||||||||||
| 62 | 2 | ▶ | use Scrappy; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 0 | my $spidy = Scrappy->new; | |||||||||||||||||||
| 65 | 0 | my $url = $self->{url}; | |||||||||||||||||||
| 66 | 0 | $self->{prefixes} = ""; | |||||||||||||||||||
| 67 | 0 | $url =~ s/\|ASN\|/$asn/; | |||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | $spidy->crawl( | ||||||||||||||||||||
| 70 | $url, | ||||||||||||||||||||
| 71 | { | ||||||||||||||||||||
| 72 | 0 | ▶ | 'table td a' => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 73 | 0 | my $data = shift->text; | |||||||||||||||||||
| 74 | 0 | ▶ | if ( defined($data) ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 75 | 0 | ▶ | if ( !( $data =~ m/W/ ) ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | 0 | $self->{prefixes} = $self->{prefixes} . $data . "\n"; | |||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | } | ||||||||||||||||||||
| 79 | 0 | else { $self->{prefixes} = undef; } | |||||||||||||||||||
| 80 | }} | ||||||||||||||||||||
| 81 | 0 | ); | |||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 0 | return $self; | |||||||||||||||||||
| 84 | } | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 0 | ▶ | sub getPrefixes { | ||||||||||||||||||
|
Subroutine
getPrefixes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 87 | 0 | my ($self) = @_; | |||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 0 | return $self->{prefixes}; | |||||||||||||||||||
| 90 | } | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | 0 | ▶ | sub getOrigin { | ||||||||||||||||||
|
Subroutine
getOrigin: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 93 | 0 | my ($self) = @_; | |||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | 0 | return $self->{get}{'origin'}; | |||||||||||||||||||
| 96 | } | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 0 | ▶ | sub getDescr { | ||||||||||||||||||
|
Subroutine
getDescr: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 99 | 0 | my ($self) = @_; | |||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | 0 | return $self->{get}{'descr'}; | |||||||||||||||||||
| 102 | } | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | 0 | ▶ | sub getRoute { | ||||||||||||||||||
|
Subroutine
getRoute: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 105 | 0 | my ($self) = @_; | |||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | 0 | return $self->{get}{'route'}; | |||||||||||||||||||
| 108 | } | ||||||||||||||||||||
| 109 | 2 | 1; # End of Net::Whois::RIS | |||||||||||||||||||
| 110 | __END__ | ||||||||||||||||||||