Skip to content

Commit

Permalink
Updated .IO, .AC, .SH, .TM parsers to the latest response
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Jun 25, 2019
1 parent 9db810d commit 85c956c
Show file tree
Hide file tree
Showing 35 changed files with 403 additions and 280 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This project uses [Semantic Versioning 2.0.0](http://semver.org/).
#### master

- CHANGED: Updated .ORG parser to the latest response (GH-98, GH-97). [Thanks @talarini]
- CHANGED: Updated .IO, .AC, .SH, .TM parsers to the latest response.
- CHANGED: Renamed WhoisDomainKg to WhoisKg (GH-48)


Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec = Gem::Specification.new do |s|
Dir.glob("{lib}/**/*")
s.require_paths = %w( lib )

s.add_dependency "whois", ">= 4.0.6"
s.add_dependency "whois", ">= 4.0.7"
s.add_dependency "activesupport", ">= 4"

s.add_development_dependency "rake"
Expand Down
6 changes: 3 additions & 3 deletions lib/whois/parsers/base_icann_compliant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ class BaseIcannCompliant < Base


property_supported :registrant_contacts do
build_contact('Registrant', Parser::Contact::TYPE_REGISTRANT)
build_contact("Registrant", Parser::Contact::TYPE_REGISTRANT)
end

property_supported :admin_contacts do
build_contact('Admin', Parser::Contact::TYPE_ADMINISTRATIVE)
build_contact("Admin", Parser::Contact::TYPE_ADMINISTRATIVE)
end

property_supported :technical_contacts do
build_contact('Tech', Parser::Contact::TYPE_TECHNICAL)
build_contact("Tech", Parser::Contact::TYPE_TECHNICAL)
end


Expand Down
73 changes: 16 additions & 57 deletions lib/whois/parsers/base_icb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,85 +7,44 @@
#++


require_relative 'base'
require_relative 'base_icann_compliant'


module Whois
class Parsers

class BaseIcb < Base
class BaseIcb < BaseIcannCompliant

property_not_supported :disclaimer


property_supported :domain do
if registered?
content_for_scanner.match(/^Domain : (.+)\n/)[1]
elsif available?
content_for_scanner.match(/^Domain (.+) is available/)[1]
end
end

property_not_supported :domain_id
self.scanner = Scanners::BaseIcannCompliant, {
pattern_available: /^NOT FOUND/
}


property_supported :status do
if available?
:available
else
:registered
end
end

property_supported :available? do
!!(content_for_scanner =~ /^Domain (.+?) is available/)
end

property_supported :registered? do
!available?
end


property_not_supported :created_on
property_not_supported :disclaimer

property_not_supported :updated_on

property_supported :expires_on do
if content_for_scanner =~ /Expiry : (.+?)\n/
parse_time($1)
node("Registry Expiry Date") do |value|
parse_time(value)
end
end


property_not_supported :registrar

property_supported :registrant_contacts do
lines = content_for_scanner.scan(/^Owner\s+: (.+)\n/).flatten
return if lines.empty?

Parser::Contact.new(
type: Parser::Contact::TYPE_REGISTRANT,
name: lines[0],
organization: lines[1],
address: lines[2],
zip: nil,
state: lines[4],
city: lines[3],
country: lines[5]
)
node("Registrant Organization") do
Parser::Contact.new({
type: Parser::Contact::TYPE_REGISTRANT,
organization: node("Registrant Organization"),
state: node("Registrant State/Province"),
country_code: node("Registrant Country"),
})
end
end

property_not_supported :admin_contacts

property_not_supported :technical_contacts


property_supported :nameservers do
content_for_scanner.scan(/^NS \d\s+: (.+)/).flatten.map do |name|
Parser::Nameserver.new(name: name)
end
end

end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/whois/parsers/whois.nic.io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class WhoisNicIo < BaseIcb

# NEWPROPERTY
def reserved?
!!content_for_scanner.match(/^Domain reserved\n/)
!!(content_for_scanner =~ /^Reserved by Registry\n/)
end

end
Expand Down
74 changes: 70 additions & 4 deletions lib/whois/parsers/whois.nic.tm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#++


require_relative 'base_icb'
require_relative 'base'


module Whois
Expand All @@ -18,12 +18,78 @@ class Parsers
# @see Whois::Parsers::Example
# The Example parser for the list of all available methods.
#
class WhoisNicTm < BaseIcb
class WhoisNicTm < Base

property_not_supported :expires_on
property_not_supported :disclaimer


property_not_supported :nameservers
property_supported :domain do
if registered?
content_for_scanner.match(/^Domain : (.+)\n/)[1]
elsif available?
content_for_scanner.match(/^Domain (.+) is available/)[1]
end
end

property_not_supported :domain_id


property_supported :status do
if available?
:available
else
:registered
end
end

property_supported :available? do
!!(content_for_scanner =~ /^Domain (.+?) is available/)
end

property_supported :registered? do
!available?
end


property_not_supported :created_on

property_not_supported :updated_on

property_supported :expires_on do
if content_for_scanner =~ /Expiry : (.+?)\n/
parse_time($1)
end
end


property_not_supported :registrar

property_supported :registrant_contacts do
lines = content_for_scanner.scan(/^Owner\s+: (.+)\n/).flatten
return if lines.empty?

Parser::Contact.new(
type: Parser::Contact::TYPE_REGISTRANT,
name: lines[0],
organization: lines[1],
address: lines[2],
zip: nil,
state: lines[4],
city: lines[3],
country: lines[5]
)
end

property_not_supported :admin_contacts

property_not_supported :technical_contacts


property_supported :nameservers do
content_for_scanner.scan(/^NS \d\s+: (.+)/).flatten.map do |name|
Parser::Nameserver.new(name: name)
end
end

end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@


#domain
%s == "u34jedzcq.ac"
%s == nil

#domain_id
%s %ERROR{AttributeNotSupported}
%s == nil


#status
Expand All @@ -20,17 +20,17 @@


#created_on
%s %ERROR{AttributeNotSupported}
%s == nil

#updated_on
%s %ERROR{AttributeNotSupported}
%s == nil

#expires_on
%s == nil


#registrar
%s %ERROR{AttributeNotSupported}
%s == nil

#registrant_contacts
%s %CLASS{array}
Expand Down
8 changes: 6 additions & 2 deletions spec/fixtures/responses/whois.nic.ac/ac/status_available.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
NOT FOUND
>>> Last update of WHOIS database: 2019-06-25T20:33:38Z <<<

Access to WHOIS information provided by Internet Computer Bureau Ltd. ("ICB") is provided to assist persons in determining the contents of a domain name registration record in the ICB registry database. The data in this record is provided by ICB for informational purposes only, and ICB does not guarantee its accuracy. This service is intended only for query-based access. You agree that you will use this data only for lawful purposes and that, under no circumstances will you use this data to(i) allow, enable, or otherwise support the transmission by e-mail, telephone, facsimile or other electronic means of mass, unsolicited, commercial advertising or solicitations to entities other than the data recipient's own existing customers; or (ii) enable high volume, automated, electronic processes that send queries or data to the systems of Registry Operator, a Registrar, or ICB or its services providers except as reasonably necessary to register domain names or modify existing registrations. UK privacy laws limit the scope of information permitted for certain public access. Therefore, concerns regarding abusive use of domain registrations in the ICB registry should be directed to either (a) the Registrar of Record as indicated in the WHOIS output, or (b) the ICB anti-abuse department at abuse@icbregistry.info.

Domain u34jedzcq.ac is available for purchase
Please visit http://www.nic.ac/ for more information
All rights reserved. ICB reserves the right to modify these terms at any time. By submitting this query, you agree to abide by these policies

The Registrar of Record identified in this output may have an RDDS service that can be queried for additional information on how to contact the Registrant, Admin, or Tech contact of the queried domain name.
28 changes: 17 additions & 11 deletions spec/fixtures/responses/whois.nic.ac/ac/status_registered.expected
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
%s == "google.ac"

#domain_id
%s %ERROR{AttributeNotSupported}
%s == "D503300000040385778-LRMS"


#status
Expand All @@ -20,33 +20,39 @@


#created_on
%s %ERROR{AttributeNotSupported}
%s %CLASS{time}
%s %TIME{2006-04-03 13:38:02 UTC}

#updated_on
%s %ERROR{AttributeNotSupported}
%s %CLASS{time}
%s %TIME{2019-03-02T10:33:12 UTC}

#expires_on
%s %CLASS{time}
%s %TIME{2014-04-03}
%s %TIME{2020-04-03 13:38:02 UTC}


#registrar
%s %ERROR{AttributeNotSupported}
%s %CLASS{registrar}
%s.id == "292"
%s.name == "MarkMonitor Inc."
%s.organization == "MarkMonitor Inc."
%s.url == "http://www.markmonitor.com"

#registrant_contacts
%s %CLASS{array}
%s %SIZE{1}
%s[0] %CLASS{contact}
%s[0].type == Whois::Parser::Contact::TYPE_REGISTRANT
%s[0].id == nil
%s[0].name == "DNS Admin"
%s[0].organization == "Google Inc."
%s[0].address == "1600 Amphitheatre Parkway"
%s[0].city == "Mountain View"
%s[0].name == nil
%s[0].organization == "Google LLC"
%s[0].address == nil
%s[0].city == nil
%s[0].zip == nil
%s[0].state == "CA"
%s[0].country == "US"
%s[0].country_code == nil
%s[0].country == nil
%s[0].country_code == "US"
%s[0].phone == nil
%s[0].fax == nil
%s[0].email == nil
Expand Down
47 changes: 32 additions & 15 deletions spec/fixtures/responses/whois.nic.ac/ac/status_registered.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
Domain Name: GOOGLE.AC
Registry Domain ID: D503300000040385778-LRMS
Registrar WHOIS Server: whois.markmonitor.com
Registrar URL: http://www.markmonitor.com
Updated Date: 2019-03-02T10:33:12Z
Creation Date: 2006-04-03T13:38:02Z
Registry Expiry Date: 2020-04-03T13:38:02Z
Registrar Registration Expiration Date:
Registrar: MarkMonitor Inc.
Registrar IANA ID: 292
Registrar Abuse Contact Email: abusecomplaints@markmonitor.com
Registrar Abuse Contact Phone: +1.2083895740
Reseller:
Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited
Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited
Registrant Organization: Google LLC
Registrant State/Province: CA
Registrant Country: US
Name Server: NS1.GOOGLE.COM
Name Server: NS2.GOOGLE.COM
Name Server: NS3.GOOGLE.COM
Name Server: NS4.GOOGLE.COM
DNSSEC: unsigned

>>> Last update of WHOIS database: 2019-06-25T20:33:47Z <<<

For more information on Whois status codes, please visit https://icann.org/epp

Access to WHOIS information provided by Internet Computer Bureau Ltd. ("ICB") is provided to assist persons in determining the contents of a domain name registration record in the ICB registry database. The data in this record is provided by ICB for informational purposes only, and ICB does not guarantee its accuracy. This service is intended only for query-based access. You agree that you will use this data only for lawful purposes and that, under no circumstances will you use this data to(i) allow, enable, or otherwise support the transmission by e-mail, telephone, facsimile or other electronic means of mass, unsolicited, commercial advertising or solicitations to entities other than the data recipient's own existing customers; or (ii) enable high volume, automated, electronic processes that send queries or data to the systems of Registry Operator, a Registrar, or ICB or its services providers except as reasonably necessary to register domain names or modify existing registrations. UK privacy laws limit the scope of information permitted for certain public access. Therefore, concerns regarding abusive use of domain registrations in the ICB registry should be directed to either (a) the Registrar of Record as indicated in the WHOIS output, or (b) the ICB anti-abuse department at abuse@icbregistry.info.

Domain : google.ac
Status : Live
Expiry : 2014-04-03

NS 1 : ns1.google.com
NS 2 : ns2.google.com
NS 3 : ns3.google.com
NS 4 : ns4.google.com

Owner : DNS Admin
Owner : Google Inc.
Owner : 1600 Amphitheatre Parkway
Owner : Mountain View
Owner : CA
Owner : US
All rights reserved. ICB reserves the right to modify these terms at any time. By submitting this query, you agree to abide by these policies

The Registrar of Record identified in this output may have an RDDS service that can be queried for additional information on how to contact the Registrant, Admin, or Tech contact of the queried domain name.

This file was deleted.

Loading

0 comments on commit 85c956c

Please sign in to comment.