| 1 | ## Domain Registry Interface, Whois commands for .WS (RFC3912) | ||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2008,2009,2013 Patrick Mevzek <netdri@dotandco.com>. All rights reserved. | ||||||||||||||||||||||||||||
| 4 | ## | ||||||||||||||||||||||||||||
| 5 | ## This file is part of Net::DRI | ||||||||||||||||||||||||||||
| 6 | ## | ||||||||||||||||||||||||||||
| 7 | ## Net::DRI is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 8 | ## it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||
| 9 | ## the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||
| 10 | ## (at your option) any later version. | ||||||||||||||||||||||||||||
| 11 | ## | ||||||||||||||||||||||||||||
| 12 | ## See the LICENSE file that comes with this distribution for more details. | ||||||||||||||||||||||||||||
| 13 | #################################################################################################### | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | package Net::DRI::Protocol::Whois::Domain::WS; | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Net::DRI::Exception; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Net::DRI::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =pod | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =head1 NAME | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | Net::DRI::Protocol::Whois::Domain::WS - .WS Whois commands (RFC3912) for Net::DRI | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | Please see the README file for details. | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | For now, support questions should be sent to: | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | Please also see the SUPPORT file in the distribution. | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt> | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | Patrick Mevzek, E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | Copyright (c) 2008,2009,2013 Patrick Mevzek <netdri@dotandco.com>. | ||||||||||||||||||||||||||||
| 52 | All rights reserved. | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 55 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||
| 56 | the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||
| 57 | (at your option) any later version. | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | See the LICENSE file that comes with this distribution for more details. | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =cut | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | #################################################################################################### | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | sub register_commands | ||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | my ($class,$version)=@_; | ||||||||||||||||||||||||||
|
Subroutine
register_commands: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 68 | 0 | return { 'domain' => { info => [ \&info, \&info_parse ] } }; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | sub info | ||||||||||||||||||||||||||||
| 72 | { | ||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my ($po,$domain,$rd)=@_; | ||||||||||||||||||||||||||
|
Subroutine
info: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 74 | 0 | my $mes=$po->message(); | |||||||||||||||||||||||||||
| 75 | 0 | ▶ | Net::DRI::Exception->die(1,'protocol/whois',10,'Invalid domain name: '.$domain) unless Net::DRI::Util::is_hostname($domain); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 0 | $mes->command('domain '.lc($domain)); | |||||||||||||||||||||||||||
| 77 | 0 | return; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | sub info_parse | ||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||
| 82 | 0 | ▶ | my ($po,$otype,$oaction,$oname,$rinfo)=@_; | ||||||||||||||||||||||||||
|
Subroutine
info_parse: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 83 | 0 | my $mes=$po->message(); | |||||||||||||||||||||||||||
| 84 | 0 | ▶ | return unless $mes->is_success(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | my $rr=$mes->response(); | |||||||||||||||||||||||||||
| 87 | 0 | my $rd=$mes->response_raw(); | |||||||||||||||||||||||||||
| 88 | 0 | my ($domain,$exist)=parse_domain($po,$rr,$rd,$rinfo); | |||||||||||||||||||||||||||
| 89 | 0 | ▶ | $domain=lc($oname) unless defined($domain); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 0 | $rinfo->{domain}->{$domain}->{exist}=$exist; | |||||||||||||||||||||||||||
| 91 | 0 | $rinfo->{domain}->{$domain}->{action}='info'; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | return unless $exist; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | parse_registrar($po,$domain,$rr,$rinfo); | |||||||||||||||||||||||||||
| 96 | 0 | parse_contacts($po,$domain,$rr,$rinfo); | |||||||||||||||||||||||||||
| 97 | 0 | parse_dates($po,$domain,$rd,$rinfo); | |||||||||||||||||||||||||||
| 98 | 0 | parse_ns($po,$domain,$rd,$rinfo); | |||||||||||||||||||||||||||
| 99 | 0 | return; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | sub parse_domain | ||||||||||||||||||||||||||||
| 103 | { | ||||||||||||||||||||||||||||
| 104 | 0 | ▶ | my ($po,$rr,$rd,$rinfo)=@_; | ||||||||||||||||||||||||||
|
Subroutine
parse_domain: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 105 | 0 | my ($dom,$e); | |||||||||||||||||||||||||||
| 106 | 0 | ▶ | if (exists($rr->{'Domain Name'})) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||
| 108 | 0 | $e=1; | |||||||||||||||||||||||||||
| 109 | 0 | $dom=lc($rr->{'Domain Name'}->[0]); | |||||||||||||||||||||||||||
| 110 | } else ## may also be invalid domain name or reserved domain name | ||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||
| 112 | 0 | $e=0; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | 0 | return ($dom,$e); | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | ## Does not seem to be always there ! (present for whatever.ws, not present for website.ws) | ||||||||||||||||||||||||||||
| 118 | sub parse_registrar | ||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||
| 120 | 0 | ▶ | my ($po,$domain,$rr,$rinfo)=@_; | ||||||||||||||||||||||||||
|
Subroutine
parse_registrar: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | $rinfo->{domain}->{$domain}->{clName}=$rr->{'Registrar Name'}->[0] if (exists($rr->{'Registrar Name'}) && $rr->{'Registrar Name'}->[0]) ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $rr->{"Registrar Name"} and $rr->{"Registrar Name"}[0]
MC/DC0%0/2
exists $rr->{"Registrar Name"} and $rr->{"Registrar Name"}[0]
exists $rr->{"Registrar Name"}
$rr->{"Registrar Name"}[0]
Truth table0%0/3
A and B
A= exists $rr->{"Registrar Name"}B= $rr->{"Registrar Name"}[0]
| |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | $rinfo->{domain}->{$domain}->{clEmail}=$rr->{'Registrar Email'}->[0] if (exists($rr->{'Registrar Email'}) && $rr->{'Registrar Email'}->[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $rr->{"Registrar Email"} and $rr->{"Registrar Email"}[0]
MC/DC0%0/2
exists $rr->{"Registrar Email"} and $rr->{"Registrar Email"}[0]
exists $rr->{"Registrar Email"}
$rr->{"Registrar Email"}[0]
Truth table0%0/3
A and B
A= exists $rr->{"Registrar Email"}B= $rr->{"Registrar Email"}[0]
| |||||||||||||||||||||||||||||
| 123 | 0 | ▶ | $rinfo->{domain}->{$domain}->{clVoice}=$rr->{'Registrar Telephone'}->[0] if (exists($rr->{'Registrar Telephone'}) && $rr->{'Registrar Telephone'}->[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $rr->{"Registrar Telephone"} and $rr->{"Registrar Telephone"}[0]
MC/DC0%0/2
exists $rr->{"Registrar Telephone"} and $rr->{"Registrar Telephone"}[0]
exists $rr->{"Registrar Telephone"}
$rr->{"Registrar Telephone"}[0]
Truth table0%0/3
A and B
A= exists $rr->{"Registrar Telephone"}B= $rr->{"Registrar Telephone"}[0]
| |||||||||||||||||||||||||||||
| 124 | 0 | ▶ | $rinfo->{domain}->{$domain}->{clWhois}=$rr->{'Registrar Whois'}->[0] if (exists($rr->{'Registrar Whois'}) &&$rr->{'Registrar Whois'}->[0]) ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $rr->{"Registrar Whois"} and $rr->{"Registrar Whois"}[0]
MC/DC0%0/2
exists $rr->{"Registrar Whois"} and $rr->{"Registrar Whois"}[0]
exists $rr->{"Registrar Whois"}
$rr->{"Registrar Whois"}[0]
Truth table0%0/3
A and B
A= exists $rr->{"Registrar Whois"}B= $rr->{"Registrar Whois"}[0]
| |||||||||||||||||||||||||||||
| 125 | 0 | return; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | ## Does not seem to be always there (see previous example, opposite case) | ||||||||||||||||||||||||||||
| 129 | sub parse_contacts | ||||||||||||||||||||||||||||
| 130 | { | ||||||||||||||||||||||||||||
| 131 | 0 | ▶ | my ($po,$domain,$rr,$rinfo)=@_; | ||||||||||||||||||||||||||
|
Subroutine
parse_contacts: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 132 | 0 | my $cs=$po->create_local_object('contactset'); | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if (exists($rr->{'Registrant Name'}) && $rr->{'Registrant Name'}->[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $rr->{"Registrant Name"} and $rr->{"Registrant Name"}[0]
MC/DC0%0/2
exists $rr->{"Registrant Name"} and $rr->{"Registrant Name"}[0]
exists $rr->{"Registrant Name"}
$rr->{"Registrant Name"}[0]
Truth table0%0/3
A and B
A= exists $rr->{"Registrant Name"}B= $rr->{"Registrant Name"}[0]
| |||||||||||||||||||||||||||||
| 135 | { | ||||||||||||||||||||||||||||
| 136 | 0 | my $c=$po->create_local_object('contact'); | |||||||||||||||||||||||||||
| 137 | 0 | $c->name($rr->{'Registrant Name'}->[0]); | |||||||||||||||||||||||||||
| 138 | 0 | $c->email($rr->{'Registrant Email'}->[0]); | |||||||||||||||||||||||||||
| 139 | 0 | $cs->add($c,'registrant'); | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if (exists($rr->{'Administrative Contact Email'}) && $rr->{'Administrative Contact Email'}->[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $rr->{"Administrative Contact Email"} and $rr->{"Administrative Contact Email"}[0]
MC/DC0%0/2
exists $rr->{"Administrative Contact Email"} and $rr->{"Administrative Contact Email"}[0]
exists $rr->{"Administrative Contact Email"}
$rr->{"Administrative Contact Email"}[0]
Truth table0%0/3
A and B
A= exists $rr->{"Administrative Contact Email"}B= $rr->{"Administrative Contact Email"}[0]
| |||||||||||||||||||||||||||||
| 142 | { | ||||||||||||||||||||||||||||
| 143 | 0 | my $c=$po->create_local_object('contact'); | |||||||||||||||||||||||||||
| 144 | 0 | $c->email($rr->{'Administrative Contact Email'}->[0]); | |||||||||||||||||||||||||||
| 145 | 0 | $c->voice($rr->{'Administrative Contact Telephone'}->[0]); | |||||||||||||||||||||||||||
| 146 | 0 | $cs->add($c,'admin'); | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | 0 | $rinfo->{domain}->{$domain}->{contact}=$cs; | |||||||||||||||||||||||||||
| 149 | 0 | return; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | sub parse_dates | ||||||||||||||||||||||||||||
| 153 | { | ||||||||||||||||||||||||||||
| 154 | 0 | ▶ | my ($po,$domain,$rd,$rinfo)=@_; | ||||||||||||||||||||||||||
|
Subroutine
parse_dates: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 155 | 0 | my $strp=$po->build_strptime_parser(pattern => '%Y-%m-%d %T', time_zone => 'America/Los_Angeles'); | |||||||||||||||||||||||||||
| 156 | 0 | my @tmp; | |||||||||||||||||||||||||||
| 157 | 0 | @tmp=grep { m/Domain created on/ } @$rd; | |||||||||||||||||||||||||||
| 158 | 0 | ▶ | $rinfo->{domain}->{$domain}->{crDate}=$strp->parse_datetime(($tmp[0]=~m/^\s+Domain created on (\S+ \S+)\s*$/)[0]) if @tmp; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 0 | @tmp=grep { m/Domain last updated on/ } @$rd; | |||||||||||||||||||||||||||
| 160 | 0 | ▶ | $rinfo->{domain}->{$domain}->{upDate}=$strp->parse_datetime(($tmp[0]=~m/^\s+Domain last updated on (\S+ \S+)\s*$/)[0]) if @tmp; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | 0 | return; | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | sub parse_ns | ||||||||||||||||||||||||||||
| 165 | { | ||||||||||||||||||||||||||||
| 166 | 0 | ▶ | my ($po,$domain,$rd,$rinfo)=@_; | ||||||||||||||||||||||||||
|
Subroutine
parse_ns: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 167 | 0 | my @ns; | |||||||||||||||||||||||||||
| 168 | 0 | foreach my $l (@$rd) | |||||||||||||||||||||||||||
| 169 | { | ||||||||||||||||||||||||||||
| 170 | 0 | ▶ | next unless (($l=~m/^\s+ Current Nameservers:/)..1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | push @ns,$1 if ($l=~m/^\s*(\S+[^\.])\.?\s*$/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | 0 | ▶ | $rinfo->{domain}->{$domain}->{ns}=$po->create_local_object('hosts')->set(@ns) if @ns; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | 0 | return; | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | #################################################################################################### | ||||||||||||||||||||||||||||
| 178 | 1 | 1; | |||||||||||||||||||||||||||