diff --git a/lib/whois/parsers/whois.corehub.net.rb b/lib/whois/parsers/whois.corehub.net.rb new file mode 100644 index 00000000..203df6b1 --- /dev/null +++ b/lib/whois/parsers/whois.corehub.net.rb @@ -0,0 +1,65 @@ +#-- +# Ruby Whois +# +# An intelligent pure Ruby WHOIS client and parser. +# +# Copyright (c) 2009-2018 Simone Carletti +#++ + + +require_relative 'base_icann_compliant' + + +module Whois + class Parsers + + class WhoisCorehubNet < BaseIcannCompliant + self.scanner = Scanners::BaseIcannCompliant, { + pattern_available: /^No match for/ + } + + property_not_supported :updated_on + + property_supported :registrant_contacts do + build_contact("Registrant", Parser::Contact::TYPE_REGISTRANT) + end + + property_supported :admin_contacts do + build_contact("Admin", Parser::Contact::TYPE_ADMINISTRATIVE) + end + + property_supported :technical_contacts do + build_contact("Tech", Parser::Contact::TYPE_TECHNICAL) + end + + property_supported :nameservers do + Array.wrap(node("Name Server")).reject(&:empty?).map do |line| + server = line.match(/^(?[^ ]+)(?: (?\d{1,3}(?:\.\d{1,3})+))?(?: (?[\da-fA-F:]+))?(?: (?\d{1,3}(?:\.\d{1,3})+))?$/) + Parser::Nameserver.new(name: server["name"].strip.downcase, ipv4: server["ipv4"], ipv6: server["ipv6"]) + end + end + + private + + def build_contact(element, type) + node("#{element} Name") do + Parser::Contact.new( + type: type, + id: node("Registry #{element} ID").presence, + name: value_for_property(element, 'Name'), + organization: value_for_property(element, 'Organization'), + address: value_for_property(element, 'Street'), + city: value_for_property(element, 'City'), + zip: value_for_property(element, 'Postal Code'), + state: value_for_property(element, 'State/Province'), + country_code: value_for_property(element, 'Country'), + phone: value_for_phone_property(element, 'Phone'), + fax: value_for_phone_property(element, 'Fax'), + email: value_for_property(element, 'Email') + ) + end + end + + end + end +end diff --git a/spec/fixtures/responses/whois.corehub.net/status_available.expected b/spec/fixtures/responses/whois.corehub.net/status_available.expected new file mode 100644 index 00000000..57f95b81 --- /dev/null +++ b/spec/fixtures/responses/whois.corehub.net/status_available.expected @@ -0,0 +1,39 @@ +#domain + %s == nil + +#domain_id + %s == nil + +#status + %s == :available + +#available? + %s == true + +#registered? + %s == false + +#created_on + %s == nil + +#expires_on + %s == nil + +#registrar + %s == nil + +#registrant_contacts + %s %CLASS{array} + %s == [] + +#admin_contacts + %s %CLASS{array} + %s == [] + +#technical_contacts + %s %CLASS{array} + %s == [] + +#nameservers + %s %CLASS{array} + %s == [] diff --git a/spec/fixtures/responses/whois.corehub.net/status_available.txt b/spec/fixtures/responses/whois.corehub.net/status_available.txt new file mode 100644 index 00000000..e4f27a4a --- /dev/null +++ b/spec/fixtures/responses/whois.corehub.net/status_available.txt @@ -0,0 +1,74 @@ +% The requested domain "u34jedzcq.net" is not registered through COREhub. +% Therefore the Whois server "whois.verisign-grs.com" is asked instead. +% +% **** Start of data fetched from referral whois **** + +[whois.verisign-grs.com] +No match for domain "U34JEDZCQ.NET". +>>> Last update of whois database: 2018-05-03T13:23:46Z <<< + +NOTICE: The expiration date displayed in this record is the date the +registrar's sponsorship of the domain name registration in the registry is +currently set to expire. This date does not necessarily reflect the expiration +date of the domain name registrant's agreement with the sponsoring +registrar. Users may consult the sponsoring registrar's Whois database to +view the registrar's reported date of expiration for this registration. + +TERMS OF USE: You are not authorized to access or query our Whois +database through the use of electronic processes that are high-volume and +automated except as reasonably necessary to register domain names or +modify existing registrations; the Data in VeriSign Global Registry +Services' ("VeriSign") Whois database is provided by VeriSign for +information purposes only, and to assist persons in obtaining information +about or related to a domain name registration record. VeriSign does not +guarantee its accuracy. By submitting a Whois query, you agree to abide +by the following terms of use: You agree that you may use this Data only +for lawful purposes and that under no circumstances will you use this Data +to: (1) allow, enable, or otherwise support the transmission of mass +unsolicited, commercial advertising or solicitations via e-mail, telephone, +or facsimile; or (2) enable high volume, automated, electronic processes +that apply to VeriSign (or its computer systems). The compilation, +repackaging, dissemination or other use of this Data is expressly +prohibited without the prior written consent of VeriSign. You agree not to +use electronic processes that are automated and high-volume to access or +query the Whois database except as reasonably necessary to register +domain names or modify existing registrations. VeriSign reserves the right +to restrict your access to the Whois database in its sole discretion to ensure +operational stability. VeriSign may restrict or terminate your access to the +Whois database for failure to abide by these terms of use. VeriSign +reserves the right to modify these terms at any time. + +The Registry database contains ONLY .COM, .NET, .EDU domains and +Registrars. + +% **** End of data fetched from referral whois **** +% +% (c) 2014 COREhub S.R.L.U. ("COREhub"). All rights reserved. +% +% NOTICE: Access to the domains information is provided to assist in +% determining the contents of a domain name registration record in the +% COREhub database. The data in this record is provided by COREhub for +% informational purposes only, and COREhub does not guarantee its +% accuracy. This service is intended only for query-based access. You +% are not authorized to access or query our Whois database through the +% use of electronic processes that are high-volume and automated except +% as reasonably necessary to register domain names or modify existing +% registrations. +% +% By submitting a Whois query, you agree that you will use this data +% only for lawful purposes and that, under no circumstances, will you +% use this data (i) to allow, enable, or otherwise support the +% transmission by e-mail, telephone, postal mail, facsimile or other +% means of mass unsolicited, commercial advertising or solicitations to +% entities other than the data recipient's own existing customers; +% and/or (ii) to enable high volume, automated, electronic processes +% that send queries or data to the COREhub systems, except as reasonably +% necessary to register domain names or modify existing registrations. +% +% The compilation, repackaging, dissemination or other use of the data +% in the COREhub Whois database is expressly prohibited without the +% prior written consent of COREhub. COREhub reserves the right to +% restrict your access to the Whois database in its sole discretion to +% ensure operational stability. COREhub may restrict or terminate your +% access to the Whois database for failure to abide by these terms of +% use. COREhub reserves the right to modify these terms at any time. diff --git a/spec/fixtures/responses/whois.corehub.net/status_registered.expected b/spec/fixtures/responses/whois.corehub.net/status_registered.expected new file mode 100644 index 00000000..b544a0a0 --- /dev/null +++ b/spec/fixtures/responses/whois.corehub.net/status_registered.expected @@ -0,0 +1,93 @@ +#domain + %s == "corehub.net" + +#domain_id + %s == "D-179116748-CONE" + +#status + %s == :registered + +#available? + %s == false + +#registered? + %s == true + +#created_on + %s %CLASS{time} + %s %TIME{2012-07-14 16:04:42 UTC} + +#expires_on + %s %CLASS{time} + %s %TIME{2018-07-14 16:04:42 UTC} + +#registrar + %s %CLASS{registrar} + %s.id == "15" + %s.name == "CORE-901 (Axone/Secretariat Maintenance Account)" + %s.organization == "CORE-901 (Axone/Secretariat Maintenance Account)" + %s.url == "http://corehub.net" + +#registrant_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_REGISTRANT + %s[0].name == "CORE ASSOCIATION" + %s[0].organization == "" + %s[0].address == "" + %s[0].city == "Geneva" + %s[0].zip == "CH-1215" + %s[0].state == "GE" + %s[0].country_code == "CH" + %s[0].phone == "+41.229295744" + %s[0].fax == "+41.229295745" + %s[0].email == "secretariat@corenic.org" + +#admin_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_ADMINISTRATIVE + %s[0].name == "CORE Secretariat" + %s[0].organization == "CORE Association" + %s[0].address == "cour de Rive 2" + %s[0].city == "Geneve" + %s[0].zip == "1204" + %s[0].state == "GE" + %s[0].country_code == "CH" + %s[0].phone == "+41.223125610" + %s[0].fax == "" + %s[0].email == "secretariat@corenic.org" + +#technical_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_TECHNICAL + %s[0].name == "CORE Secretariat" + %s[0].organization == "CORE Association" + %s[0].address == "cour de Rive 2" + %s[0].city == "Geneve" + %s[0].zip == "1204" + %s[0].state == "GE" + %s[0].country_code == "CH" + %s[0].phone == "+41.223125610" + %s[0].fax == "" + %s[0].email == "secretariat@corenic.org" + +#nameservers + %s %CLASS{array} + %s %SIZE{3} + %s[0] %CLASS{nameserver} + %s[0].name == "us20-west.irondns.net" + %s[0].ipv4 == "104.225.5.66" + %s[0].ipv6 == "2607:fc50:2000:2001::2" + %s[1] %CLASS{nameserver} + %s[1].name == "hk21.irondns.net" + %s[1].ipv4 == "103.6.86.97" + %s[1].ipv6 == "2403:2500:8000:1::9f9" + %s[2] %CLASS{nameserver} + %s[2].name == "us19-east.irondns.net" + %s[2].ipv4 == "4.71.215.210" + %s[2].ipv6 == "2001:1900:2236::d2" diff --git a/spec/fixtures/responses/whois.corehub.net/status_registered.txt b/spec/fixtures/responses/whois.corehub.net/status_registered.txt new file mode 100644 index 00000000..d3657e8a --- /dev/null +++ b/spec/fixtures/responses/whois.corehub.net/status_registered.txt @@ -0,0 +1,89 @@ +Domain Name: corehub.net +Registry Domain ID: D-179116748-CONE +Registrar WHOIS Server: whois.corehub.net +Registrar URL: http://corehub.net +Creation Date: 2012-07-14T16:04:42.0Z +Registrar Registration Expiration Date: 2018-07-14T16:04:42.0Z +Registrar: CORE-901 (Axone/Secretariat Maintenance Account) +Registrar IANA ID: 15 +Registrar Abuse Contact Email: abuse@corehub.net +Registrar Abuse Contact Phone: +34.935275235 +Domain Status: ok https://www.icann.org/epp#ok +Registry Registrant ID: COCO-1883998 +Registrant Name: CORE ASSOCIATION +Registrant Organization: +Registrant Street: +Registrant City: Geneva +Registrant State/Province: GE +Registrant Postal Code: CH-1215 +Registrant Country: CH +Registrant Phone: +41.229295744 +Registrant Phone Ext: +Registrant Fax: +41.229295745 +Registrant Fax Ext: +Registrant Email: secretariat@corenic.org +Registry Admin ID: COCO-354 +Admin Name: CORE Secretariat +Admin Organization: CORE Association +Admin Street: cour de Rive 2 +Admin City: Geneve +Admin State/Province: GE +Admin Postal Code: 1204 +Admin Country: CH +Admin Phone: +41.223125610 +Admin Phone Ext: +Admin Fax: +Admin Fax Ext: +Admin Email: secretariat@corenic.org +Registry Tech ID: COCO-354 +Tech Name: CORE Secretariat +Tech Organization: CORE Association +Tech Street: cour de Rive 2 +Tech City: Geneve +Tech State/Province: GE +Tech Postal Code: 1204 +Tech Country: CH +Tech Phone: +41.223125610 +Tech Phone Ext: +Tech Fax: +Tech Fax Ext: +Tech Email: secretariat@corenic.org +Name Server: us20-west.irondns.net 104.225.5.66 2607:fc50:2000:2001::2 +Name Server: hk21.irondns.net 2403:2500:8000:1::9f9 103.6.86.97 +Name Server: us19-east.irondns.net 4.71.215.210 2001:1900:2236::d2 +DNSSEC: unsigned +URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net +>>> Last update of WHOIS database: 2018-05-03T13:22:13.239Z <<< + +% (c) 2014 COREhub S.R.L.U. ("COREhub"). All rights reserved. +% +% NOTICE: Access to the domains information is provided to assist in +% determining the contents of a domain name registration record in the +% COREhub database. The data in this record is provided by COREhub for +% informational purposes only, and COREhub does not guarantee its +% accuracy. This service is intended only for query-based access. You +% are not authorized to access or query our Whois database through the +% use of electronic processes that are high-volume and automated except +% as reasonably necessary to register domain names or modify existing +% registrations. +% +% By submitting a Whois query, you agree that you will use this data +% only for lawful purposes and that, under no circumstances, will you +% use this data (i) to allow, enable, or otherwise support the +% transmission by e-mail, telephone, postal mail, facsimile or other +% means of mass unsolicited, commercial advertising or solicitations to +% entities other than the data recipient's own existing customers; +% and/or (ii) to enable high volume, automated, electronic processes +% that send queries or data to the COREhub systems, except as reasonably +% necessary to register domain names or modify existing registrations. +% +% The compilation, repackaging, dissemination or other use of the data +% in the COREhub Whois database is expressly prohibited without the +% prior written consent of COREhub. COREhub reserves the right to +% restrict your access to the Whois database in its sole discretion to +% ensure operational stability. COREhub may restrict or terminate your +% access to the Whois database for failure to abide by these terms of +% use. COREhub reserves the right to modify these terms at any time. +% +% For more information on Whois status codes, please visit +% https://icann.org/epp diff --git a/spec/whois/parsers/responses/whois.corehub.net/status_available_spec.rb b/spec/whois/parsers/responses/whois.corehub.net/status_available_spec.rb new file mode 100644 index 00000000..071de4c4 --- /dev/null +++ b/spec/whois/parsers/responses/whois.corehub.net/status_available_spec.rb @@ -0,0 +1,88 @@ +# encoding: utf-8 + +# This file is autogenerated. Do not edit it manually. +# If you want change the content of this file, edit +# +# /spec/fixtures/responses/whois.corehub.net/status_available.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.corehub.net.rb' + +describe Whois::Parsers::WhoisCorehubNet, "status_available.expected" do + + subject do + file = fixture("responses", "whois.corehub.net/status_available.txt") + part = Whois::Record::Part.new(body: File.read(file)) + described_class.new(part) + end + + describe "#domain" do + it do + expect(subject.domain).to eq(nil) + end + end + describe "#domain_id" do + it do + expect(subject.domain_id).to eq(nil) + end + end + describe "#status" do + it do + expect(subject.status).to eq(:available) + end + end + describe "#available?" do + it do + expect(subject.available?).to eq(true) + end + end + describe "#registered?" do + it do + expect(subject.registered?).to eq(false) + end + end + describe "#created_on" do + it do + expect(subject.created_on).to eq(nil) + end + end + describe "#expires_on" do + it do + expect(subject.expires_on).to eq(nil) + end + end + describe "#registrar" do + it do + expect(subject.registrar).to eq(nil) + end + end + describe "#registrant_contacts" do + it do + expect(subject.registrant_contacts).to be_a(Array) + expect(subject.registrant_contacts).to eq([]) + end + end + describe "#admin_contacts" do + it do + expect(subject.admin_contacts).to be_a(Array) + expect(subject.admin_contacts).to eq([]) + end + end + describe "#technical_contacts" do + it do + expect(subject.technical_contacts).to be_a(Array) + expect(subject.technical_contacts).to eq([]) + end + end + describe "#nameservers" do + it do + expect(subject.nameservers).to be_a(Array) + expect(subject.nameservers).to eq([]) + end + end +end diff --git a/spec/whois/parsers/responses/whois.corehub.net/status_registered_spec.rb b/spec/whois/parsers/responses/whois.corehub.net/status_registered_spec.rb new file mode 100644 index 00000000..d5444327 --- /dev/null +++ b/spec/whois/parsers/responses/whois.corehub.net/status_registered_spec.rb @@ -0,0 +1,142 @@ +# encoding: utf-8 + +# This file is autogenerated. Do not edit it manually. +# If you want change the content of this file, edit +# +# /spec/fixtures/responses/whois.corehub.net/status_registered.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.corehub.net.rb' + +describe Whois::Parsers::WhoisCorehubNet, "status_registered.expected" do + + subject do + file = fixture("responses", "whois.corehub.net/status_registered.txt") + part = Whois::Record::Part.new(body: File.read(file)) + described_class.new(part) + end + + describe "#domain" do + it do + expect(subject.domain).to eq("corehub.net") + end + end + describe "#domain_id" do + it do + expect(subject.domain_id).to eq("D-179116748-CONE") + end + end + describe "#status" do + it do + expect(subject.status).to eq(:registered) + end + end + describe "#available?" do + it do + expect(subject.available?).to eq(false) + end + end + describe "#registered?" do + it do + expect(subject.registered?).to eq(true) + end + end + describe "#created_on" do + it do + expect(subject.created_on).to be_a(Time) + expect(subject.created_on).to eq(Time.parse("2012-07-14 16:04:42 UTC")) + end + end + describe "#expires_on" do + it do + expect(subject.expires_on).to be_a(Time) + expect(subject.expires_on).to eq(Time.parse("2018-07-14 16:04:42 UTC")) + end + end + describe "#registrar" do + it do + expect(subject.registrar).to be_a(Whois::Parser::Registrar) + expect(subject.registrar.id).to eq("15") + expect(subject.registrar.name).to eq("CORE-901 (Axone/Secretariat Maintenance Account)") + expect(subject.registrar.organization).to eq("CORE-901 (Axone/Secretariat Maintenance Account)") + expect(subject.registrar.url).to eq("http://corehub.net") + end + end + describe "#registrant_contacts" do + it do + expect(subject.registrant_contacts).to be_a(Array) + expect(subject.registrant_contacts.size).to eq(1) + expect(subject.registrant_contacts[0]).to be_a(Whois::Parser::Contact) + expect(subject.registrant_contacts[0].type).to eq(Whois::Parser::Contact::TYPE_REGISTRANT) + expect(subject.registrant_contacts[0].name).to eq("CORE ASSOCIATION") + expect(subject.registrant_contacts[0].organization).to eq("") + expect(subject.registrant_contacts[0].address).to eq("") + expect(subject.registrant_contacts[0].city).to eq("Geneva") + expect(subject.registrant_contacts[0].zip).to eq("CH-1215") + expect(subject.registrant_contacts[0].state).to eq("GE") + expect(subject.registrant_contacts[0].country_code).to eq("CH") + expect(subject.registrant_contacts[0].phone).to eq("+41.229295744") + expect(subject.registrant_contacts[0].fax).to eq("+41.229295745") + expect(subject.registrant_contacts[0].email).to eq("secretariat@corenic.org") + end + end + describe "#admin_contacts" do + it do + expect(subject.admin_contacts).to be_a(Array) + expect(subject.admin_contacts.size).to eq(1) + expect(subject.admin_contacts[0]).to be_a(Whois::Parser::Contact) + expect(subject.admin_contacts[0].type).to eq(Whois::Parser::Contact::TYPE_ADMINISTRATIVE) + expect(subject.admin_contacts[0].name).to eq("CORE Secretariat") + expect(subject.admin_contacts[0].organization).to eq("CORE Association") + expect(subject.admin_contacts[0].address).to eq("cour de Rive 2") + expect(subject.admin_contacts[0].city).to eq("Geneve") + expect(subject.admin_contacts[0].zip).to eq("1204") + expect(subject.admin_contacts[0].state).to eq("GE") + expect(subject.admin_contacts[0].country_code).to eq("CH") + expect(subject.admin_contacts[0].phone).to eq("+41.223125610") + expect(subject.admin_contacts[0].fax).to eq("") + expect(subject.admin_contacts[0].email).to eq("secretariat@corenic.org") + end + end + describe "#technical_contacts" do + it do + expect(subject.technical_contacts).to be_a(Array) + expect(subject.technical_contacts.size).to eq(1) + expect(subject.technical_contacts[0]).to be_a(Whois::Parser::Contact) + expect(subject.technical_contacts[0].type).to eq(Whois::Parser::Contact::TYPE_TECHNICAL) + expect(subject.technical_contacts[0].name).to eq("CORE Secretariat") + expect(subject.technical_contacts[0].organization).to eq("CORE Association") + expect(subject.technical_contacts[0].address).to eq("cour de Rive 2") + expect(subject.technical_contacts[0].city).to eq("Geneve") + expect(subject.technical_contacts[0].zip).to eq("1204") + expect(subject.technical_contacts[0].state).to eq("GE") + expect(subject.technical_contacts[0].country_code).to eq("CH") + expect(subject.technical_contacts[0].phone).to eq("+41.223125610") + expect(subject.technical_contacts[0].fax).to eq("") + expect(subject.technical_contacts[0].email).to eq("secretariat@corenic.org") + end + end + describe "#nameservers" do + it do + expect(subject.nameservers).to be_a(Array) + expect(subject.nameservers.size).to eq(3) + expect(subject.nameservers[0]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[0].name).to eq("us20-west.irondns.net") + expect(subject.nameservers[0].ipv4).to eq("104.225.5.66") + expect(subject.nameservers[0].ipv6).to eq("2607:fc50:2000:2001::2") + expect(subject.nameservers[1]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[1].name).to eq("hk21.irondns.net") + expect(subject.nameservers[1].ipv4).to eq("103.6.86.97") + expect(subject.nameservers[1].ipv6).to eq("2403:2500:8000:1::9f9") + expect(subject.nameservers[2]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[2].name).to eq("us19-east.irondns.net") + expect(subject.nameservers[2].ipv4).to eq("4.71.215.210") + expect(subject.nameservers[2].ipv6).to eq("2001:1900:2236::d2") + end + end +end