whois 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +0 -1
- data/Rakefile +25 -1
- data/lib/whois/definitions/tlds.rb +1 -1
- data/lib/whois/record/parser/base.rb +1 -1
- data/lib/whois/record/parser/base_afilias.rb +2 -2
- data/lib/whois/record/parser/jobswhois.verisign-grs.com.rb +1 -1
- data/lib/whois/record/parser/whois.audns.net.au.rb +81 -16
- data/lib/whois/record/parser/whois.biz.rb +1 -1
- data/lib/whois/record/parser/whois.cctld.by.rb +107 -0
- data/lib/whois/record/parser/whois.centralnic.com.rb +1 -1
- data/lib/whois/record/parser/whois.cira.ca.rb +103 -51
- data/lib/whois/record/parser/whois.cnnic.cn.rb +1 -1
- data/lib/whois/record/parser/whois.crsnic.net.rb +1 -1
- data/lib/whois/record/parser/whois.denic.de.rb +1 -1
- data/lib/whois/record/parser/whois.dns.hr.rb +2 -2
- data/lib/whois/record/parser/whois.domainregistry.ie.rb +77 -21
- data/lib/whois/record/parser/whois.domainregistry.my.rb +5 -8
- data/lib/whois/record/parser/whois.dreamhost.com.rb +1 -1
- data/lib/whois/record/parser/whois.enom.com.rb +124 -0
- data/lib/whois/record/parser/whois.fi.rb +1 -1
- data/lib/whois/record/parser/whois.iana.org.rb +1 -1
- data/lib/whois/record/parser/whois.nc.rb +2 -2
- data/lib/whois/record/parser/whois.nic.cc.rb +1 -1
- data/lib/whois/record/parser/whois.nic.hu.rb +1 -1
- data/lib/whois/record/parser/whois.nic.it.rb +1 -1
- data/lib/whois/record/parser/whois.nic.lk.rb +1 -1
- data/lib/whois/record/parser/whois.nic.tv.rb +1 -1
- data/lib/whois/record/parser/whois.registry.qa.rb +1 -1
- data/lib/whois/record/parser/whois.rnids.rs.rb +4 -4
- data/lib/whois/record/parser/whois.smallregistry.net.rb +1 -1
- data/lib/whois/record/parser/whois.tld.ee.rb +1 -1
- data/lib/whois/record/parser/whois.ua.rb +1 -1
- data/lib/whois/record/scanners/afilias.rb +60 -0
- data/lib/whois/record/scanners/ast.rb +67 -0
- data/lib/whois/record/scanners/base.rb +102 -0
- data/lib/whois/record/scanners/iana.rb +101 -0
- data/lib/whois/record/scanners/verisign.rb +112 -0
- data/lib/whois/record/scanners/whois.audns.net.au.rb +39 -0
- data/lib/whois/record/scanners/whois.biz.rb +47 -0
- data/lib/whois/record/scanners/whois.cctld.by.rb +46 -0
- data/lib/whois/record/scanners/whois.centralnic.com.rb +46 -0
- data/lib/whois/record/scanners/whois.cira.ca.rb +87 -0
- data/lib/whois/record/scanners/whois.cnnic.cn.rb +44 -0
- data/lib/whois/record/scanners/whois.denic.de.rb +122 -0
- data/lib/whois/record/scanners/whois.dns.hr.rb +39 -0
- data/lib/whois/record/scanners/whois.domainregistry.ie.rb +50 -0
- data/lib/whois/record/scanners/whois.nc.rb +46 -0
- data/lib/whois/record/scanners/whois.nic.hu.rb +178 -0
- data/lib/whois/record/scanners/whois.nic.it.rb +104 -0
- data/lib/whois/record/scanners/whois.registry.qa.rb +39 -0
- data/lib/whois/record/scanners/whois.rnids.rs.rb +75 -0
- data/lib/whois/record/scanners/whois.smallregistry.net.rb +61 -0
- data/lib/whois/record/scanners/whois.tld.ee.rb +50 -0
- data/lib/whois/version.rb +1 -1
- data/spec/fixtures/responses/whois.audns.net.au/status_available.expected +33 -0
- data/spec/fixtures/responses/whois.audns.net.au/status_registered.expected +53 -0
- data/spec/fixtures/responses/whois.cctld.by/status_available.expected +54 -0
- data/spec/fixtures/responses/whois.cctld.by/status_available.txt +1 -0
- data/spec/fixtures/responses/whois.cctld.by/status_registered.expected +64 -0
- data/spec/fixtures/responses/whois.cctld.by/status_registered.txt +11 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_autorenew_grace.expected → property_status_autorenew_grace.expected} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_autorenew_grace.txt → property_status_autorenew_grace.txt} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_available.expected → property_status_available.expected} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_available.txt → property_status_available.txt} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_redemption.expected → property_status_redemption.expected} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_redemption.txt → property_status_redemption.txt} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_registered.expected → property_status_registered.expected} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_registered.txt → property_status_registered.txt} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_tobereleased.expected → property_status_tobereleased.expected} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_tobereleased.txt → property_status_tobereleased.txt} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_unavailable.txt → property_status_unavailable.txt} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/status_available.expected +64 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/status_available.txt → status_available.txt} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/status_invalid.expected → status_invalid.expected} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/status_invalid.txt → status_invalid.txt} +0 -0
- data/spec/fixtures/responses/whois.cira.ca/status_registered.expected +118 -0
- data/spec/fixtures/responses/whois.cira.ca/{schema-2/status_registered.txt → status_registered.txt} +11 -10
- data/spec/fixtures/responses/whois.domainregistry.ie/status_available.expected +34 -0
- data/spec/fixtures/responses/whois.domainregistry.ie/status_available.txt +2 -4
- data/spec/fixtures/responses/whois.domainregistry.ie/status_registered.expected +47 -1
- data/spec/fixtures/responses/whois.domainregistry.ie/status_registered.txt +5 -6
- data/spec/fixtures/responses/whois.enom.com/property_contacts_almost_empty.expected +31 -0
- data/spec/fixtures/responses/whois.enom.com/property_contacts_almost_empty.txt +61 -0
- data/spec/fixtures/responses/whois.enom.com/property_contacts_long_address.expected +15 -0
- data/spec/fixtures/responses/whois.enom.com/property_contacts_long_address.txt +67 -0
- data/spec/fixtures/responses/whois.enom.com/status_registered.expected +97 -0
- data/spec/fixtures/responses/whois.enom.com/status_registered.txt +68 -0
- data/spec/fixtures/responses/whois.nic.it/status_registered.expected +25 -25
- data/spec/whois/record/parser/responses/whois.audns.net.au/status_available_spec.rb +47 -0
- data/spec/whois/record/parser/responses/whois.audns.net.au/status_registered_spec.rb +67 -0
- data/spec/whois/record/parser/responses/whois.cctld.by/status_available_spec.rb +105 -0
- data/spec/whois/record/parser/responses/whois.cctld.by/status_registered_spec.rb +115 -0
- data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/property_status_autorenew_grace_spec.rb → property_status_autorenew_grace_spec.rb} +2 -2
- data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/property_status_available_spec.rb → property_status_available_spec.rb} +2 -2
- data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/property_status_redemption_spec.rb → property_status_redemption_spec.rb} +2 -2
- data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/property_status_registered_spec.rb → property_status_registered_spec.rb} +2 -2
- data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/property_status_tobereleased_spec.rb → property_status_tobereleased_spec.rb} +2 -2
- data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/status_available_spec.rb → status_available_spec.rb} +45 -2
- data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/status_invalid_spec.rb → status_invalid_spec.rb} +2 -2
- data/spec/whois/record/parser/responses/whois.cira.ca/status_registered_spec.rb +172 -0
- data/spec/whois/record/parser/responses/whois.domainregistry.ie/status_available_spec.rb +48 -0
- data/spec/whois/record/parser/responses/whois.domainregistry.ie/status_registered_spec.rb +61 -1
- data/spec/whois/record/parser/responses/whois.enom.com/property_contacts_almost_empty_spec.rb +60 -0
- data/spec/whois/record/parser/responses/whois.enom.com/property_contacts_long_address_spec.rb +42 -0
- data/spec/whois/record/parser/responses/whois.enom.com/status_registered_spec.rb +140 -0
- data/spec/whois/record/parser/responses/whois.nic.it/status_registered_spec.rb +25 -25
- data/whois.gemspec +8 -7
- metadata +101 -61
- data/lib/whois/record/parser/scanners/afilias.rb +0 -66
- data/lib/whois/record/parser/scanners/ast.rb +0 -69
- data/lib/whois/record/parser/scanners/base.rb +0 -85
- data/lib/whois/record/parser/scanners/iana.rb +0 -108
- data/lib/whois/record/parser/scanners/verisign.rb +0 -122
- data/lib/whois/record/parser/scanners/whois.biz.rb +0 -49
- data/lib/whois/record/parser/scanners/whois.centralnic.com.rb +0 -52
- data/lib/whois/record/parser/scanners/whois.cnnic.cn.rb +0 -46
- data/lib/whois/record/parser/scanners/whois.denic.de.rb +0 -124
- data/lib/whois/record/parser/scanners/whois.dns.hr.rb +0 -41
- data/lib/whois/record/parser/scanners/whois.nc.rb +0 -48
- data/lib/whois/record/parser/scanners/whois.nic.hu.rb +0 -180
- data/lib/whois/record/parser/scanners/whois.nic.it.rb +0 -111
- data/lib/whois/record/parser/scanners/whois.registry.qa.rb +0 -41
- data/lib/whois/record/parser/scanners/whois.rnids.rs.rb +0 -78
- data/lib/whois/record/parser/scanners/whois.smallregistry.net.rb +0 -62
- data/lib/whois/record/parser/scanners/whois.tld.ee.rb +0 -52
- data/spec/fixtures/responses/whois.cira.ca/schema-1/status_available.expected +0 -27
- data/spec/fixtures/responses/whois.cira.ca/schema-1/status_available.txt +0 -9
- data/spec/fixtures/responses/whois.cira.ca/schema-1/status_registered.expected +0 -46
- data/spec/fixtures/responses/whois.cira.ca/schema-1/status_registered.txt +0 -47
- data/spec/fixtures/responses/whois.cira.ca/schema-2/status_available.expected +0 -34
- data/spec/fixtures/responses/whois.cira.ca/schema-2/status_registered.expected +0 -48
- data/spec/whois/record/parser/responses/whois.cira.ca/schema-1/status_available_spec.rb +0 -65
- data/spec/whois/record/parser/responses/whois.cira.ca/schema-1/status_registered_spec.rb +0 -84
- data/spec/whois/record/parser/responses/whois.cira.ca/schema-2/status_registered_spec.rb +0 -89
@@ -8,39 +8,51 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
require 'whois/record/parser/base'
|
11
|
+
require 'whois/record/scanners/whois.domainregistry.ie.rb'
|
11
12
|
|
12
13
|
|
13
14
|
module Whois
|
14
15
|
class Record
|
15
16
|
class Parser
|
16
17
|
|
17
|
-
#
|
18
|
-
# = whois.domainregistry.ie parser
|
19
|
-
#
|
20
18
|
# Parser for the whois.domainregistry.ie server.
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
# Please consider to contribute implementing missing methods.
|
25
|
-
# See WhoisNicIt parser for an explanation of all available methods
|
26
|
-
# and examples.
|
19
|
+
#
|
20
|
+
# @see Whois::Record::Parser::Example
|
21
|
+
# The Example parser for the list of all available methods.
|
27
22
|
#
|
28
23
|
class WhoisDomainregistryIe < Base
|
24
|
+
include Scanners::Ast
|
25
|
+
|
26
|
+
property_supported :disclaimer do
|
27
|
+
node("field:disclaimer")
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
property_supported :domain do
|
32
|
+
node("domain")
|
33
|
+
end
|
34
|
+
|
35
|
+
property_not_supported :domain_id
|
36
|
+
|
37
|
+
|
38
|
+
property_not_supported :referral_whois
|
39
|
+
|
40
|
+
property_not_supported :referral_url
|
41
|
+
|
29
42
|
|
30
43
|
property_supported :status do
|
31
|
-
|
32
|
-
|
33
|
-
when "active" then :registered
|
34
|
-
else
|
35
|
-
Whois.bug!(ParserError, "Unknown status `#{$1}'.")
|
36
|
-
end
|
37
|
-
else
|
44
|
+
case node("status", &:downcase)
|
45
|
+
when nil
|
38
46
|
:available
|
47
|
+
when "active"
|
48
|
+
:registered
|
49
|
+
else
|
50
|
+
Whois.bug!(ParserError, "Unknown status `#{node("status")}'.")
|
39
51
|
end
|
40
52
|
end
|
41
53
|
|
42
54
|
property_supported :available? do
|
43
|
-
!!(
|
55
|
+
!!node("status:available")
|
44
56
|
end
|
45
57
|
|
46
58
|
property_supported :registered? do
|
@@ -53,16 +65,60 @@ module Whois
|
|
53
65
|
property_not_supported :updated_on
|
54
66
|
|
55
67
|
property_supported :expires_on do
|
56
|
-
|
57
|
-
|
68
|
+
node("renewal") { |value| Time.parse(value) }
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
property_not_supported :registrar
|
73
|
+
|
74
|
+
|
75
|
+
property_supported :registrant_contacts do
|
76
|
+
node("descr") do |array|
|
77
|
+
Record::Contact.new(
|
78
|
+
:type => Whois::Record::Contact::TYPE_REGISTRANT,
|
79
|
+
:id => nil,
|
80
|
+
:name => array[0]
|
81
|
+
)
|
58
82
|
end
|
59
83
|
end
|
60
84
|
|
85
|
+
property_supported :admin_contacts do
|
86
|
+
build_contact("admin-c", Whois::Record::Contact::TYPE_ADMIN)
|
87
|
+
end
|
88
|
+
|
89
|
+
property_supported :technical_contacts do
|
90
|
+
build_contact("tech-c", Whois::Record::Contact::TYPE_TECHNICAL)
|
91
|
+
end
|
92
|
+
|
61
93
|
|
62
94
|
property_supported :nameservers do
|
63
|
-
|
95
|
+
Array.wrap(node("nserver")).map do |line|
|
64
96
|
name, ipv4 = line.split(/\s+/)
|
65
|
-
Record::Nameserver.new(name, ipv4)
|
97
|
+
Record::Nameserver.new(:name => name, :ipv4 => ipv4)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
# Initializes a new {Scanners::WhoisDomainregistryIe} instance
|
103
|
+
# passing the {#content_for_scanner}
|
104
|
+
# and calls +parse+ on it.
|
105
|
+
#
|
106
|
+
# @return [Hash]
|
107
|
+
def parse
|
108
|
+
Scanners::WhoisDomainregistryIe.new(content_for_scanner).parse
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
private
|
113
|
+
|
114
|
+
def build_contact(element, type)
|
115
|
+
node(element) do |id|
|
116
|
+
contact = node("field:#{id}")
|
117
|
+
Record::Contact.new(
|
118
|
+
:type => type,
|
119
|
+
:id => id,
|
120
|
+
:name => contact["person"]
|
121
|
+
)
|
66
122
|
end
|
67
123
|
end
|
68
124
|
|
@@ -14,17 +14,14 @@ module Whois
|
|
14
14
|
class Record
|
15
15
|
class Parser
|
16
16
|
|
17
|
-
#
|
18
|
-
# = whois.domainregistry.my parser
|
19
|
-
#
|
20
17
|
# Parser for the whois.domainregistry.my server.
|
21
18
|
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
# See WhoisNicIt parser for an explanation of all available methods
|
26
|
-
# and examples.
|
19
|
+
# @note This parser is just a stub and provides only a few basic methods
|
20
|
+
# to check for domain availability and get domain status.
|
21
|
+
# Please consider to contribute implementing missing methods.
|
27
22
|
#
|
23
|
+
# @see Whois::Record::Parser::Example
|
24
|
+
# The Example parser for the list of all available methods.
|
28
25
|
class WhoisDomainregistryMy < Base
|
29
26
|
|
30
27
|
property_supported :status do
|
@@ -0,0 +1,124 @@
|
|
1
|
+
#--
|
2
|
+
# Ruby Whois
|
3
|
+
#
|
4
|
+
# An intelligent pure Ruby WHOIS client and parser.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
|
7
|
+
#++
|
8
|
+
|
9
|
+
|
10
|
+
require 'whois/record/parser/base'
|
11
|
+
|
12
|
+
|
13
|
+
module Whois
|
14
|
+
class Record
|
15
|
+
class Parser
|
16
|
+
|
17
|
+
# Parser for the whois.enom.com server.
|
18
|
+
#
|
19
|
+
# @note This parser is just a stub and provides only a few basic methods
|
20
|
+
# to check for domain availability and get domain status.
|
21
|
+
# Please consider to contribute implementing missing methods.
|
22
|
+
#
|
23
|
+
# @see Whois::Record::Parser::Example
|
24
|
+
# The Example parser for the list of all available methods.
|
25
|
+
#
|
26
|
+
# @since 2.5.0
|
27
|
+
class WhoisEnomCom < Base
|
28
|
+
|
29
|
+
property_not_supported :status
|
30
|
+
|
31
|
+
# The server is contacted only in case of a registered domain.
|
32
|
+
property_supported :available? do
|
33
|
+
false
|
34
|
+
end
|
35
|
+
|
36
|
+
property_supported :registered? do
|
37
|
+
true
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
property_supported :created_on do
|
42
|
+
if content_for_scanner =~ /Creation date: (.+)\n/
|
43
|
+
Time.parse($1)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
property_not_supported :updated_on
|
48
|
+
|
49
|
+
property_supported :expires_on do
|
50
|
+
if content_for_scanner =~ /Expiration date: (.+)\n/
|
51
|
+
Time.parse($1)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
property_supported :registrar do
|
57
|
+
Record::Registrar.new(
|
58
|
+
:name => "eNom Inc.",
|
59
|
+
:url => "http://www.enom.com/"
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
property_supported :registrant_contacts do
|
64
|
+
build_contact("Registrant Contact", Record::Contact::TYPE_REGISTRANT)
|
65
|
+
end
|
66
|
+
|
67
|
+
property_supported :admin_contacts do
|
68
|
+
build_contact("Administrative Contact", Record::Contact::TYPE_ADMIN)
|
69
|
+
end
|
70
|
+
|
71
|
+
property_supported :technical_contacts do
|
72
|
+
build_contact("Technical Contact", Record::Contact::TYPE_TECHNICAL)
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
property_supported :nameservers do
|
77
|
+
if content_for_scanner =~ /Name Servers:\n((\s+[^\s]+\n)+)/
|
78
|
+
$1.split("\n").map do |line|
|
79
|
+
Record::Nameserver.new(:name => line.strip)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def build_contact(element, type)
|
88
|
+
match = content_for_scanner.slice(/#{element}:\n((.+\n)+)/, 1)
|
89
|
+
return unless match
|
90
|
+
|
91
|
+
# 0 AdBrite, Inc.
|
92
|
+
# 1 Host Master (hostmaster@adbrite.com)
|
93
|
+
# 2 4159750916
|
94
|
+
# 3 Fax:
|
95
|
+
# 4 731 Market Street, Suite 500
|
96
|
+
# 5 San Francisco, CA 94103
|
97
|
+
# 6 US
|
98
|
+
|
99
|
+
lines = match.split("\n").map(&:lstrip)
|
100
|
+
name, email = lines[1].match(/(.+) \((.*)\)/)[1..2].map(&:strip)
|
101
|
+
fax = lines[3].match(/Fax: (.*)/)[1]
|
102
|
+
city, state, zip = lines[-2].match(/(.*),(.+?)(\d*)$/)[1..3].map(&:strip)
|
103
|
+
|
104
|
+
Record::Contact.new(
|
105
|
+
:type => type,
|
106
|
+
:id => nil,
|
107
|
+
:name => name,
|
108
|
+
:organization => lines[0],
|
109
|
+
:address => lines[4..-3].join("\n"),
|
110
|
+
:city => city,
|
111
|
+
:zip => zip,
|
112
|
+
:state => state,
|
113
|
+
:country_code => lines[-1],
|
114
|
+
:phone => lines[2],
|
115
|
+
:fax => fax,
|
116
|
+
:email => email
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
require 'whois/record/parser/base'
|
11
|
-
require 'whois/record/
|
11
|
+
require 'whois/record/scanners/whois.nc.rb'
|
12
12
|
|
13
13
|
|
14
14
|
module Whois
|
@@ -20,7 +20,7 @@ module Whois
|
|
20
20
|
# @see Whois::Record::Parser::Example
|
21
21
|
# The Example parser for the list of all available methods.
|
22
22
|
#
|
23
|
-
# @since
|
23
|
+
# @since 2.4.0
|
24
24
|
class WhoisNc < Base
|
25
25
|
include Scanners::Ast
|
26
26
|
|
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
require 'whois/record/parser/base'
|
11
|
-
require 'whois/record/
|
11
|
+
require 'whois/record/scanners/whois.rnids.rs.rb'
|
12
12
|
|
13
13
|
|
14
14
|
module Whois
|
@@ -20,7 +20,7 @@ module Whois
|
|
20
20
|
# @see Whois::Record::Parser::Example
|
21
21
|
# The Example parser for the list of all available methods.
|
22
22
|
#
|
23
|
-
# @since
|
23
|
+
# @since 2.4.0
|
24
24
|
class WhoisRnidsRs < Base
|
25
25
|
include Scanners::Ast
|
26
26
|
|
@@ -40,13 +40,13 @@ module Whois
|
|
40
40
|
|
41
41
|
|
42
42
|
property_supported :status do
|
43
|
-
case
|
43
|
+
case node("Domain status", &:downcase)
|
44
44
|
when nil
|
45
45
|
:available
|
46
46
|
when "active"
|
47
47
|
:registered
|
48
48
|
else
|
49
|
-
Whois.bug!(ParserError, "Unknown status `#{
|
49
|
+
Whois.bug!(ParserError, "Unknown status `#{node("Domain status")}'.")
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#--
|
2
|
+
# Ruby Whois
|
3
|
+
#
|
4
|
+
# An intelligent pure Ruby WHOIS client and parser.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
|
7
|
+
#++
|
8
|
+
|
9
|
+
|
10
|
+
require 'whois/record/scanners/base'
|
11
|
+
|
12
|
+
|
13
|
+
module Whois
|
14
|
+
class Record
|
15
|
+
module Scanners
|
16
|
+
|
17
|
+
# Scanner for the Afilias record.
|
18
|
+
class Afilias < Base
|
19
|
+
|
20
|
+
self.tokenizers += [
|
21
|
+
:skip_empty_line,
|
22
|
+
:scan_available,
|
23
|
+
:scan_reserved,
|
24
|
+
:scan_throttled,
|
25
|
+
:scan_disclaimer,
|
26
|
+
:scan_keyvalue,
|
27
|
+
]
|
28
|
+
|
29
|
+
|
30
|
+
tokenizer :scan_available do
|
31
|
+
if @input.scan(/^NOT FOUND\n/)
|
32
|
+
@ast["status:available"] = true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# .XXX
|
37
|
+
tokenizer :scan_reserved do
|
38
|
+
if @input.scan(/^Reserved by ICM Registry\n/)
|
39
|
+
@ast["status:reserved"] = true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# .ORG
|
44
|
+
tokenizer :scan_throttled do
|
45
|
+
if @input.match?(/^WHOIS LIMIT EXCEEDED/)
|
46
|
+
@ast["response:throttled"] = true
|
47
|
+
@input.skip(/^.+\n/)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
tokenizer :scan_disclaimer do
|
52
|
+
if @input.pos == 0 && @input.match?(/^(.+\n){3,}\n/)
|
53
|
+
@ast["field:disclaimer"] = _scan_lines_to_array(/^(.+)\n/).join(" ")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#--
|
2
|
+
# Ruby Whois
|
3
|
+
#
|
4
|
+
# An intelligent pure Ruby WHOIS client and parser.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
|
7
|
+
#++
|
8
|
+
|
9
|
+
|
10
|
+
require 'strscan'
|
11
|
+
|
12
|
+
|
13
|
+
module Whois
|
14
|
+
class Record
|
15
|
+
module Scanners
|
16
|
+
|
17
|
+
# The Ast module tries to emulate a super-simple Abstract Syntax Tree structure
|
18
|
+
# including method for accessing ast nodes.
|
19
|
+
#
|
20
|
+
# == Usage
|
21
|
+
#
|
22
|
+
# Include the Ast module and provide a <tt>parse</tt> instance method.
|
23
|
+
# <tt>parse</tt> should returns a Hash representing the AST.
|
24
|
+
#
|
25
|
+
# def parse
|
26
|
+
# Scanner.new.parse
|
27
|
+
# end
|
28
|
+
# # => { "created_on" => "2009-12-12", ... }
|
29
|
+
#
|
30
|
+
# Now you can access the AST using the <tt>node</tt> method.
|
31
|
+
#
|
32
|
+
# node "created_on"
|
33
|
+
# # => "2009-12-12"
|
34
|
+
#
|
35
|
+
# node? "created_on"
|
36
|
+
# # => true
|
37
|
+
#
|
38
|
+
# node? "created_at"
|
39
|
+
# # => false
|
40
|
+
#
|
41
|
+
module Ast
|
42
|
+
|
43
|
+
def node(key)
|
44
|
+
if block_given?
|
45
|
+
value = ast[key]
|
46
|
+
value = yield(value) unless value.nil?
|
47
|
+
value
|
48
|
+
else
|
49
|
+
ast[key]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def node?(key)
|
54
|
+
!ast[key].nil?
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def ast
|
60
|
+
@ast ||= parse
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
#--
|
2
|
+
# Ruby Whois
|
3
|
+
#
|
4
|
+
# An intelligent pure Ruby WHOIS client and parser.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
|
7
|
+
#++
|
8
|
+
|
9
|
+
|
10
|
+
module Whois
|
11
|
+
class Record
|
12
|
+
module Scanners
|
13
|
+
|
14
|
+
class Base
|
15
|
+
|
16
|
+
class_attribute :tokenizers
|
17
|
+
self.tokenizers = []
|
18
|
+
|
19
|
+
def self.tokenizer(name, &block)
|
20
|
+
define_method(name, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def initialize(content)
|
25
|
+
@input = StringScanner.new(content)
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse
|
29
|
+
# The temporary store.
|
30
|
+
# Scanners may use this to store pointers, states or other flags.
|
31
|
+
@tmp = {}
|
32
|
+
|
33
|
+
# A super-simple AST store.
|
34
|
+
@ast = {}
|
35
|
+
|
36
|
+
tokenize until @input.eos?
|
37
|
+
|
38
|
+
@ast
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
tokenizer :skip_empty_line do
|
43
|
+
@input.skip(/^\n/)
|
44
|
+
end
|
45
|
+
|
46
|
+
tokenizer :skip_newline do
|
47
|
+
@input.skip(/\n/)
|
48
|
+
end
|
49
|
+
|
50
|
+
tokenizer :scan_keyvalue do
|
51
|
+
if @input.scan(/(.+?):(.*?)\n/)
|
52
|
+
key, value = @input[1].strip, @input[2].strip
|
53
|
+
if @ast[key].nil?
|
54
|
+
@ast[key] = value
|
55
|
+
else
|
56
|
+
@ast[key] = Array.wrap(@ast[key])
|
57
|
+
@ast[key] << value
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
protected
|
63
|
+
|
64
|
+
def _scan_lines_to_array(pattern)
|
65
|
+
lines = []
|
66
|
+
while @input.scan(pattern)
|
67
|
+
@input[1].strip
|
68
|
+
lines << @input[1].strip
|
69
|
+
end
|
70
|
+
lines
|
71
|
+
end
|
72
|
+
|
73
|
+
def _scan_lines_to_hash(pattern)
|
74
|
+
lines = {}
|
75
|
+
while @input.scan(pattern)
|
76
|
+
lines.merge! @input[1].strip => @input[2].strip
|
77
|
+
end
|
78
|
+
lines
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def tokenize
|
84
|
+
tokenizers.each do |tokenizer|
|
85
|
+
return if send(tokenizer)
|
86
|
+
end
|
87
|
+
unexpected_token
|
88
|
+
end
|
89
|
+
|
90
|
+
def unexpected_token
|
91
|
+
error!("Unexpected token")
|
92
|
+
end
|
93
|
+
|
94
|
+
def error!(message)
|
95
|
+
raise ParserError, "#{message}: #{@input.peek(@input.string.length)}"
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|