From 7ef2153cfe1388ab99d61b98f5fb7ce2f653d049 Mon Sep 17 00:00:00 2001 From: Cork Date: Fri, 4 May 2018 13:17:05 +0200 Subject: [PATCH] Add support for whois.nameisp.com --- lib/whois/parsers/whois.nameisp.com.rb | 94 ++++++++++++ .../status_available.expected | 42 ++++++ .../whois.nameisp.com/status_available.txt | 23 +++ .../status_registered.expected | 89 +++++++++++ .../whois.nameisp.com/status_registered.txt | 74 +++++++++ .../status_available_spec.rb | 93 ++++++++++++ .../status_registered_spec.rb | 140 ++++++++++++++++++ 7 files changed, 555 insertions(+) create mode 100644 lib/whois/parsers/whois.nameisp.com.rb create mode 100644 spec/fixtures/responses/whois.nameisp.com/status_available.expected create mode 100644 spec/fixtures/responses/whois.nameisp.com/status_available.txt create mode 100644 spec/fixtures/responses/whois.nameisp.com/status_registered.expected create mode 100644 spec/fixtures/responses/whois.nameisp.com/status_registered.txt create mode 100644 spec/whois/parsers/responses/whois.nameisp.com/status_available_spec.rb create mode 100644 spec/whois/parsers/responses/whois.nameisp.com/status_registered_spec.rb diff --git a/lib/whois/parsers/whois.nameisp.com.rb b/lib/whois/parsers/whois.nameisp.com.rb new file mode 100644 index 00000000..b8d3c9f2 --- /dev/null +++ b/lib/whois/parsers/whois.nameisp.com.rb @@ -0,0 +1,94 @@ +#-- +# 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 WhoisNameispCom < BaseIcannCompliant + self.scanner = Scanners::BaseIcannCompliant, { + pattern_available: /^ERROR: domain not found:/ + } + + property_supported :domain do + node("Domain Name") + end + + property_supported :domain_id do + node("Registry Domain ID") + end + + property_supported :created_on do + node("Creation Date") { |value| parse_time(value) } + end + + property_supported :updated_on do + node("Updated Date") { |value| parse_time(value) } + end + + property_supported :expires_on do + node("Registrar Registration Expiration Date") { |value| parse_time(value) } + end + + property_supported :registrar do + return unless node("Registrar") + Parser::Registrar.new( + id: node("Registrar IANA ID"), + name: node("Registrar"), + organization: node("Registrar"), + url: node("Registrar URL") + ) + end + + 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 + + # Checks whether this response contains a message + # that can be reconducted to a "WHOIS Server Unavailable" status. + # + # @return [Boolean] + def response_unavailable? + !!node("response:unavailable") + 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.nameisp.com/status_available.expected b/spec/fixtures/responses/whois.nameisp.com/status_available.expected new file mode 100644 index 00000000..f0e6a67f --- /dev/null +++ b/spec/fixtures/responses/whois.nameisp.com/status_available.expected @@ -0,0 +1,42 @@ +#domain + %s == nil + +#domain_id + %s == nil + +#status + %s == :available + +#available? + %s == true + +#registered? + %s == false + +#created_on + %s == nil + +#updated_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.nameisp.com/status_available.txt b/spec/fixtures/responses/whois.nameisp.com/status_available.txt new file mode 100644 index 00000000..0cef4852 --- /dev/null +++ b/spec/fixtures/responses/whois.nameisp.com/status_available.txt @@ -0,0 +1,23 @@ + +ERROR: domain not found: u34jedzcq.com + +Whois server 2.5 + +The data in the www.NameISP.com whois database is provided to you for +information purposes only, that is, to assist you in obtaining information +about or related to a domain name registration record. We make this +information available "as is," and do not guarantee its accuracy. + +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 to: + +(1) enable high volume, automated, electronic processes that stress or load +this whois database system providing you this information; or +(2) allow, enable, or otherwise support the transmission of mass +unsolicited, +commercial advertising or solicitations via direct mail, electronic +mail, or by telephone. The compilation, repackaging, dissemination or +other use of this data is expressly prohibited without prior written +consent from us. + +NOTE! ALL WHOIS QUERIES AND IP ADDRESSES ARE LOGGED! diff --git a/spec/fixtures/responses/whois.nameisp.com/status_registered.expected b/spec/fixtures/responses/whois.nameisp.com/status_registered.expected new file mode 100644 index 00000000..15314145 --- /dev/null +++ b/spec/fixtures/responses/whois.nameisp.com/status_registered.expected @@ -0,0 +1,89 @@ +#domain + %s == "domain.com" + +#domain_id + %s == "93697156_DOMAIN_COM-VRSN" + +#status + %s == :registered + +#available? + %s == false + +#registered? + %s == true + +#created_on + %s %CLASS{time} + %s %TIME{2003-01-06 13:49:20 UTC} + +#updated_on + %s %CLASS{time} + %s %TIME{2017-03-20 10:43:48 UTC} + +#expires_on + %s %CLASS{time} + %s %TIME{2025-01-06 13:49:20 UTC} + +#registrar + %s %CLASS{registrar} + %s.id == "113" + %s.name == "AB NAME ISP" + %s.organization == "AB NAME ISP" + %s.url == "www.namesrs.com" + +#registrant_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_REGISTRANT + %s[0].name == "Domain Admin" + %s[0].organization == "AB Name ISP" + %s[0].address == "Radiovgen 2" + %s[0].city == "VSTRA FRLUNDA" + %s[0].zip == "421 47" + %s[0].state == "" + %s[0].country_code == "SE" + %s[0].phone == "+46.313011220" + %s[0].fax == "+46.317090850" + %s[0].email == "registry@nameisp.com" + +#admin_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_ADMINISTRATIVE + %s[0].name == "Domain Admin" + %s[0].organization == "AB Name ISP" + %s[0].address == "Radiovgen 2" + %s[0].city == "VSTRA FRLUNDA" + %s[0].zip == "421 47" + %s[0].state == "" + %s[0].country_code == "se" + %s[0].phone == "+46.313011220" + %s[0].fax == "+46.317090850" + %s[0].email == "registry@nameisp.com" + +#technical_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_TECHNICAL + %s[0].name == "Domain Admin" + %s[0].organization == "AB Name ISP" + %s[0].address == "Radiovgen 2" + %s[0].city == "VSTRA FRLUNDA" + %s[0].zip == "421 47" + %s[0].state == "" + %s[0].country_code == "SE" + %s[0].phone == "+46.313011220" + %s[0].fax == "+46.317090850" + %s[0].email == "registry@nameisp.com" + +#nameservers + %s %CLASS{array} + %s %SIZE{2} + %s[0] %CLASS{nameserver} + %s[0].name == "gene.ns.cloudflare.com" + %s[1] %CLASS{nameserver} + %s[1].name == "tim.ns.cloudflare.com" diff --git a/spec/fixtures/responses/whois.nameisp.com/status_registered.txt b/spec/fixtures/responses/whois.nameisp.com/status_registered.txt new file mode 100644 index 00000000..f5bd0e29 --- /dev/null +++ b/spec/fixtures/responses/whois.nameisp.com/status_registered.txt @@ -0,0 +1,74 @@ + + +Domain Name: nameisp.com +Registry Domain ID: 93697156_DOMAIN_COM-VRSN +Registrar WHOIS Server: whois.nameisp.com +Registrar URL: www.namesrs.com +Updated Date: 2017-03-20T10:43:48.00Z +Creation Date: 2003-01-06T13:49:20.00Z +Registrar Registration Expiration Date: 2025-01-06T13:49:20.00Z +Registrar: AB NAME ISP +Registrar IANA ID: 1371 +Registrar Abuse Contact Email: info@nameisp.com +Registrar Abuse Contact Phone: +46.313011220 +Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited +Registry Registrant ID: 793066 +Registrant Name: Domain Admin +Registrant Organization: AB Name ISP +Registrant Street: Radiovgen 2 +Registrant City: VSTRA FRLUNDA +Registrant State: +Registrant Postal Code: 421 47 +Registrant Country: SE +Registrant Phone: +46.313011220 +Registrant Fax: +46.317090850 +Registrant Email: registry@nameisp.com +Registry Admin ID: 959999 +Admin Name: Domain Admin +Admin Organization: AB Name ISP +Admin Street: Radiovgen 2 +Admin City: VSTRA FRLUNDA +Admin Postal Code: 421 47 +Admin Country: se +Admin Phone: +46.313011220 +Admin Fax: +46.317090850 +Admin Email: registry@nameisp.com +Registry Tech ID: 793066 +Tech Name: Domain Admin +Tech Organization: AB Name ISP +Tech Street: Radiovgen 2 +Tech City: VSTRA FRLUNDA +Tech Postal Code: 421 47 +Tech Country: SE +Tech Phone: +46.313011220 +Tech Fax: +46.317090850 +Tech Email: registry@nameisp.com +Name Server: GENE.NS.CLOUDFLARE.COM +Name Server: TIM.NS.CLOUDFLARE.COM +DNSSEC: Unsigned +URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/ +Last update of WHOIS database: 2018-05-03T10:01:08.00Z + +Whois information protected. +Contact the registrant via http://www.shieldwhois.com + +Whois server 2.5 + +The data in the www.NameISP.com whois database is provided to you for +information purposes only, that is, to assist you in obtaining information +about or related to a domain name registration record. We make this +information available "as is," and do not guarantee its accuracy. + +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 to: + +(1) enable high volume, automated, electronic processes that stress or load +this whois database system providing you this information; or +(2) allow, enable, or otherwise support the transmission of mass +unsolicited, +commercial advertising or solicitations via direct mail, electronic +mail, or by telephone. The compilation, repackaging, dissemination or +other use of this data is expressly prohibited without prior written +consent from us. + +NOTE! ALL WHOIS QUERIES AND IP ADDRESSES ARE LOGGED! diff --git a/spec/whois/parsers/responses/whois.nameisp.com/status_available_spec.rb b/spec/whois/parsers/responses/whois.nameisp.com/status_available_spec.rb new file mode 100644 index 00000000..2d471a08 --- /dev/null +++ b/spec/whois/parsers/responses/whois.nameisp.com/status_available_spec.rb @@ -0,0 +1,93 @@ +# 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.nameisp.com/status_available.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.nameisp.com.rb' + +describe Whois::Parsers::WhoisNameispCom, "status_available.expected" do + + subject do + file = fixture("responses", "whois.nameisp.com/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 "#updated_on" do + it do + expect(subject.updated_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.nameisp.com/status_registered_spec.rb b/spec/whois/parsers/responses/whois.nameisp.com/status_registered_spec.rb new file mode 100644 index 00000000..e9af1546 --- /dev/null +++ b/spec/whois/parsers/responses/whois.nameisp.com/status_registered_spec.rb @@ -0,0 +1,140 @@ +# 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.nameisp.com/status_registered.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.nameisp.com.rb' + +describe Whois::Parsers::WhoisNameispCom, "status_registered.expected" do + + subject do + file = fixture("responses", "whois.nameisp.com/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("nameisp.com") + end + end + describe "#domain_id" do + it do + expect(subject.domain_id).to eq("93697156_DOMAIN_COM-VRSN") + 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("2003-01-06 13:49:20 UTC")) + end + end + describe "#updated_on" do + it do + expect(subject.updated_on).to be_a(Time) + expect(subject.updated_on).to eq(Time.parse("2017-03-20 10:43:48 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("2025-01-06 13:49:20 UTC")) + end + end + describe "#registrar" do + it do + expect(subject.registrar).to be_a(Whois::Parser::Registrar) + expect(subject.registrar.id).to eq("1371") + expect(subject.registrar.name).to eq("AB NAME ISP") + expect(subject.registrar.organization).to eq("AB NAME ISP") + expect(subject.registrar.url).to eq("www.namesrs.com") + 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("Domain Admin") + expect(subject.registrant_contacts[0].organization).to eq("AB Name ISP") + expect(subject.registrant_contacts[0].address).to eq("Radiovgen 2") + expect(subject.registrant_contacts[0].city).to eq("VSTRA FRLUNDA") + expect(subject.registrant_contacts[0].zip).to eq("421 47") + expect(subject.registrant_contacts[0].state).to eq("") + expect(subject.registrant_contacts[0].country_code).to eq("SE") + expect(subject.registrant_contacts[0].phone).to eq("+46.313011220") + expect(subject.registrant_contacts[0].fax).to eq("+46.317090850") + expect(subject.registrant_contacts[0].email).to eq("registry@nameisp.com") + 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("Domain Admin") + expect(subject.admin_contacts[0].organization).to eq("AB Name ISP") + expect(subject.admin_contacts[0].address).to eq("Radiovgen 2") + expect(subject.admin_contacts[0].city).to eq("VSTRA FRLUNDA") + expect(subject.admin_contacts[0].zip).to eq("421 47") + expect(subject.admin_contacts[0].state).to eq("") + expect(subject.admin_contacts[0].country_code).to eq("se") + expect(subject.admin_contacts[0].phone).to eq("+46.313011220") + expect(subject.admin_contacts[0].fax).to eq("+46.317090850") + expect(subject.admin_contacts[0].email).to eq("registry@nameisp.com") + 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("Domain Admin") + expect(subject.technical_contacts[0].organization).to eq("AB Name ISP") + expect(subject.technical_contacts[0].address).to eq("Radiovgen 2") + expect(subject.technical_contacts[0].city).to eq("VSTRA FRLUNDA") + expect(subject.technical_contacts[0].zip).to eq("421 47") + expect(subject.technical_contacts[0].state).to eq("") + expect(subject.technical_contacts[0].country_code).to eq("SE") + expect(subject.technical_contacts[0].phone).to eq("+46.313011220") + expect(subject.technical_contacts[0].fax).to eq("+46.317090850") + expect(subject.technical_contacts[0].email).to eq("registry@nameisp.com") + end + end + describe "#nameservers" do + it do + expect(subject.nameservers).to be_a(Array) + expect(subject.nameservers.size).to eq(2) + expect(subject.nameservers[0]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[0].name).to eq("gene.ns.cloudflare.com") + expect(subject.nameservers[1]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[1].name).to eq("tim.ns.cloudflare.com") + end + end +end