| 1 | package POE::Component::Client::Whois; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 5 | $POE::Component::Client::Whois::VERSION = '1.38'; | |||||||||||||||||||||||||||||||||||||||||||||
| 3 | #ABSTRACT: A one shot non-blocking RFC 812 WHOIS query. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Socket; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use POE qw(Filter::Line Wheel::ReadWrite Wheel::SocketFactory); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use POE::Component::Client::Whois::TLDList; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use POE::Component::Client::Whois::IPBlks; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | sub whois { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
whois: called CC=16 SCAR=40.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | $args{ lc $_ } = delete $args{$_} for keys %args; | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | $args{referral} = 1 unless defined $args{referral} and !$args{referral}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $args{"referral"} and not $args{"referral"}
MC/DC0%0/2
defined $args{"referral"} and not $args{"referral"}
defined $args{"referral"}
not $args{"referral"}
Truth table33%1/3
A and not(B)
A= defined $args{"referral"}B= not $args{"referral"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | unless ( $args{query} and $args{event} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{"query"} and $args{"event"}
MC/DC0%0/2
$args{"query"} and $args{"event"}
$args{"query"}
$args{"event"}
Truth table33%1/3
A and B
A= $args{"query"}B= $args{"event"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | warn "You must provide a query string and a response event\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | ▶ | unless ( $args{host} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | my $whois_server; | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | my $tld = POE::Component::Client::Whois::TLDList->new(); | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | my $blk = POE::Component::Client::Whois::IPBlks->new(); | |||||||||||||||||||||||||||||||||||||||||||||
| 30 | SWITCH: { | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | if ( $args{query} =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$args{"query"} =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ and scalar grep(($_ >= 0 && $_ <= 255), split(/\./, $args{"query"}, 0)) == 4
$_ >= 0 && $_ <= 255
MC/DC0%0/2
$args{"query"} =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ and scalar grep(($_ >= 0 && $_ <= 255), split(/\./, $args{"query"}, 0)) == 4
$args{"query"} =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
scalar grep(($_ >= 0 && $_ <= 255), split(/\./, $args{"query"}, 0)) == 4
MC/DC0%0/2
$_ >= 0 && $_ <= 255
$_ >= 0
$_ <= 255
Truth table33%1/3
A and B
A= $args{"query"} =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/B= scalar grep(($_ >= 0 && $_ <= 255), split(/\./, $args{"query"}, 0)) == 4
Truth table0%0/3
A && B
A= $_ >= 0B= $_ <= 255
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | and | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | scalar( grep $_ >= 0 && $_ <= 255, split /\./, $args{query} ) == | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $whois_server = ( $blk->get_server( $args{query} ) )[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | unless ($whois_server) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | warn | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | "Couldn\'t determine correct whois server, falling back on arin\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $whois_server = 'whois.arin.net'; | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | last SWITCH; | |||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | ▶ | if ( $args{query} =~ /:/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | warn "IPv6 detected, defaulting to arin\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $whois_server = 'whois.arin.net'; | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | last SWITCH; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | $whois_server = ( $tld->tld( $args{query} ) )[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | if ( $whois_server eq 'ARPA' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $args{query} =~ s/\.in-addr\.arpa//; | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $args{query} = join '.', reverse split( /\./, $args{query} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $whois_server = ( $blk->get_server( $args{query} ) )[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | unless ($whois_server) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | warn | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | "Couldn\'t determine correct whois server, falling back on arin\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $whois_server = 'whois.arin.net'; | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | ▶ | unless ($whois_server) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | warn | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | "Could not automagically determine whois server from query string, defaulting to internic \n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $whois_server = 'whois.internic.net'; | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | $args{host} = $whois_server; | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | $args{session} = $poe_kernel->get_active_session() | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | ▶ | unless ( $args{session} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | my $self = bless { request => \%args }, $package; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | $self->{session_id} = POE::Session->create( | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | object_states => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | $self => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | qw(_start _connect _sock_input _sock_down _sock_up _sock_failed _time_out) | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | options => { trace => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | )->ID(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 3 | ▶ | sub _start { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_start: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | $self->{_dot_com} = ( POE::Component::Client::Whois::TLDList->new()->tld('.com') )[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | 3 | $self->{_dot_org} = ( POE::Component::Client::Whois::TLDList->new()->tld('.org') )[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | 3 | $self->{session_id} = $_[SESSION]->ID(); | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | 3 | $kernel->yield('_connect'); | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | 3 | undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 3 | ▶ | sub _connect { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_connect: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 3 | my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # Check here for NONE or WEB and send an error straight away. | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | ▶ | if ( my ($type) = $self->{request}->{host} =~ /^(NONE|WEB)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | my $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | ▶ | if ( $type eq 'NONE' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | $error = 'This TLD has no whois server.'; | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | $error = | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 'This TLD has no whois server, but you can access the ' | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | . 'whois database at ' | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | . ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | POE::Component::Client::Whois::TLDList->new->tld( | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | $self->{request}->{query} | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | )[1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | $self->{request}->{error} = $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | my $request = delete $self->{request}; | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | my $session = delete $request->{session}; | |||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | $kernel->post( $session => $request->{event} => $request ); | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | $self->{factory} = POE::Wheel::SocketFactory->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | SocketDomain => AF_INET, | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | SocketType => SOCK_STREAM, | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | SocketProtocol => 'tcp', | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | RemoteAddress => $self->{request}->{host}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | ▶ | RemotePort => $self->{request}->{port} || 43, | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'request'}{'port'} || 43
MC/DC0%0/1
$self->{'request'}{'port'} || 43
$self->{'request'}{'port'}
Truth table50%1/2
A
A= $self->{'request'}{'port'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | SuccessEvent => '_sock_up', | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | FailureEvent => '_sock_failed', | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub _sock_failed { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sock_failed: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my ( $kernel, $self, $op, $errno, $errstr ) = | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | @_[ KERNEL, OBJECT, ARG0 .. ARG2 ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | delete $self->{factory}; | |||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $self->{request}->{error} = "$op error $errno: $errstr"; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $request = delete $self->{request}; | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $session = delete $request->{session}; | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $kernel->post( $session => $request->{event} => $request ); | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | ▶ | sub _sock_up { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sock_up: called CC=3 SCAR=12.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | my ( $kernel, $self, $session, $socket ) = | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | @_[ KERNEL, OBJECT, SESSION, ARG0 ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | delete $self->{factory}; | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | $self->{'socket'} = new POE::Wheel::ReadWrite( | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | Handle => $socket, | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | Driver => POE::Driver::SysRW->new(), | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | Filter => POE::Filter::Line->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 154 | InputRegexp => '\015?\012', | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | OutputLiteral => "\015\012" | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | InputEvent => '_sock_input', | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ErrorEvent => '_sock_down', | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | unless ( $self->{'socket'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $request = delete $self->{request}; | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $session = delete $request->{session}; | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | $request->{error} = | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | "Couldn\'t create a Wheel::ReadWrite on socket for whois"; | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $kernel->post( $session => $request->{event} => $request ); | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | my $query = $self->{request}->{host} eq 'de.whois-servers.net' | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ? join(' ', '-T dn,ace -C US-ASCII', $self->{request}->{query}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | ▶ | : $self->{request}->{query}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | $self->{'socket'}->put( $query ); | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | $kernel->delay( '_time_out' => 30 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | ▶ | sub _sock_down { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sock_down: called CC=7 SCAR=27.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | delete $self->{socket}; | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | $kernel->delay( '_time_out' => undef ); | |||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | if ( $self->{request}->{referral} and $self->{_referral} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"request"}{"referral"} and $self->{"_referral"}
MC/DC0%0/2
$self->{"request"}{"referral"} and $self->{"_referral"}
$self->{"request"}{"referral"}
$self->{"_referral"}
Truth table33%1/3
A and B
A= $self->{"request"}{"referral"}B= $self->{"_referral"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | delete $self->{request}->{reply} if $self->{referral_only}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $referral = delete $self->{_referral}; | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my ($host,$port) = split /:/, $referral; | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $self->{request}->{host} = $host; | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | $self->{request}->{port} = ( $port ? $port : '43' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $kernel->yield('_connect'); | |||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | my $request = delete $self->{request}; | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | my $session = delete $request->{session}; | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | if ( defined( $request->{reply} ) and ref( $request->{reply} ) eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $request->{"reply"} and ref $request->{"reply"} eq "ARRAY"
MC/DC0%0/2
defined $request->{"reply"} and ref $request->{"reply"} eq "ARRAY"
defined $request->{"reply"}
ref $request->{"reply"} eq "ARRAY"
Truth table33%1/3
A and B
A= defined $request->{"reply"}B= ref $request->{"reply"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | delete $request->{error}; | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $request->{error} = "No information received from remote host"; | |||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | $kernel->post( $session => $request->{event} => $request ); | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 34 | ▶ | sub _sock_input { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sock_input: called CC=9 SCAR=36.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 34 | my ( $kernel, $self, $line ) = @_[ KERNEL, OBJECT, ARG0 ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | 34 | push @{ $self->{request}->{reply} }, $line; | |||||||||||||||||||||||||||||||||||||||||||||
| 211 | 34 | ▶ | if ( my ($referral) = $line =~ /ReferralServer:\s+(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my ( $scheme, $authority, $path, $query, $fragment ) = $referral =~ | |||||||||||||||||||||||||||||||||||||||||||||
| 213 | m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?|; | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | return unless $scheme and $authority; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$scheme and $authority
MC/DC0%0/2
$scheme and $authority
$scheme
$authority
Truth table0%0/3
A and B
A= $schemeB= $authority
| |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $scheme = lc $scheme; | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | return unless $scheme =~ m'r?whois'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my ( $host, $port ) = split /:/, $authority; | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | return if $host eq $self->{request}->{host}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $self->{_referral} = $authority; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 34 | ▶ | if ( ( $self->{request}->{host} eq $self->{_dot_com} or | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->{"request"}{"host"} eq $self->{"_dot_com"} || $self->{"request"}{"host"} eq $self->{"_dot_org"} and my($other) = $line =~ /Whois Server:\s+(.*)\s*$/i
$self->{"request"}{"host"} eq $self->{"_dot_com"} or $self->{"request"}{"host"} eq $self->{"_dot_org"}
MC/DC0%0/3
$self->{"request"}{"host"} eq $self->{"_dot_com"} || $self->{"request"}{"host"} eq $self->{"_dot_org"} and my($other) = $line =~ /Whois Server:\s+(.*)\s*$/i
$self->{"request"}{"host"} eq $self->{"_dot_com"}
$self->{"request"}{"host"} eq $self->{"_dot_org"}
my($other) = $line =~ /Whois Server:\s+(.*)\s*$/i
Truth table20%1/5
A or B and C
A= $self->{"request"}{"host"} eq $self->{"_dot_com"}B= $self->{"request"}{"host"} eq $self->{"_dot_org"}C= my($other) = $line =~ /Whois Server:\s+(.*)\s*$/i
| |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | $self->{request}->{host} eq $self->{_dot_org} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | and my ($other) = $line =~ /Whois Server:\s+(.*)\s*$/i ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $self->{_referral} = $other; | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 34 | undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | sub _time_out { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_time_out: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | delete $self->{'socket'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||