whois 1.0.12 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +16 -1
- data/Manifest +24 -4
- data/lib/whois.rb +5 -5
- data/lib/whois/answer.rb +6 -2
- data/lib/whois/answer/contact.rb +18 -17
- data/lib/whois/answer/parser.rb +16 -1
- data/lib/whois/answer/parser/base.rb +40 -4
- data/lib/whois/answer/parser/whois.ausregistry.net.au.rb +71 -0
- data/lib/whois/answer/parser/whois.denic.de.rb +6 -6
- data/lib/whois/answer/parser/whois.nic.ac.rb +3 -3
- data/lib/whois/answer/parser/whois.nic.am.rb +83 -0
- data/lib/whois/answer/parser/whois.nic.as.rb +73 -0
- data/lib/whois/answer/parser/whois.nic.hu.rb +7 -7
- data/lib/whois/answer/parser/whois.nic.it.rb +6 -6
- data/lib/whois/answer/parser/whois.nic.st.rb +81 -0
- data/lib/whois/answer/parser/whois.publicinterestregistry.net.rb +3 -3
- data/lib/whois/version.rb +2 -2
- data/test/answer/contact_test.rb +14 -0
- data/test/answer/parser/base_test.rb +18 -0
- data/test/answer/parser/whois.ausregistry.net.au_test.rb +70 -0
- data/test/answer/parser/whois.denic.de_test.rb +65 -44
- data/test/answer/parser/whois.eu_test.rb +1 -1
- data/test/answer/parser/whois.nic-se.se_test.rb +1 -1
- data/test/answer/parser/whois.nic.ac_test.rb +13 -13
- data/test/answer/parser/whois.nic.am_test.rb +84 -0
- data/test/answer/parser/whois.nic.as_test.rb +63 -0
- data/test/answer/parser/whois.nic.hu_test.rb +45 -35
- data/test/answer/parser/whois.nic.it_test.rb +92 -65
- data/test/answer/parser/whois.nic.st_test.rb +77 -0
- data/test/answer/parser/whois.publicinterestregistry.net_test.rb +26 -20
- data/test/answer/parser_test.rb +45 -0
- data/test/answer_test.rb +7 -0
- data/test/list_tld +4 -4
- data/test/testcases/responses/whois.ausregistry.net.au/available.txt +1 -0
- data/test/testcases/responses/whois.ausregistry.net.au/registered.txt +23 -0
- data/test/testcases/responses/whois.denic.de/{nameservers_with_ip.txt → property_nameservers_with_ip.txt} +0 -0
- data/test/testcases/responses/whois.denic.de/property_technical_contact.txt +70 -0
- data/test/testcases/responses/whois.eu/{nameservers_with_ip.txt → property_nameservers_with_ip.txt} +0 -0
- data/test/testcases/responses/whois.nic-se.se/{nameservers_with_ip.txt → property_nameservers_with_ip.txt} +0 -0
- data/test/testcases/responses/whois.nic.am/available.txt +3 -0
- data/test/testcases/responses/whois.nic.am/registered.txt +42 -0
- data/test/testcases/responses/whois.nic.as/available.txt +12 -0
- data/test/testcases/responses/whois.nic.as/registered.txt +18 -0
- data/test/testcases/responses/whois.nic.it/property_admin_contact.txt +53 -0
- data/test/testcases/responses/whois.nic.it/{contact.txt → property_registrant_contact.txt} +0 -0
- data/test/testcases/responses/whois.nic.it/property_technical_contact.txt +53 -0
- data/test/testcases/responses/whois.nic.st/available.txt +1 -0
- data/test/testcases/responses/whois.nic.st/registered.txt +47 -0
- data/whois.gemspec +5 -5
- metadata +36 -7
@@ -66,11 +66,11 @@ module Whois
|
|
66
66
|
|
67
67
|
property_not_supported :registrar
|
68
68
|
|
69
|
-
property_not_supported :
|
69
|
+
property_not_supported :registrant_contact
|
70
70
|
|
71
|
-
property_not_supported :
|
71
|
+
property_not_supported :admin_contact
|
72
72
|
|
73
|
-
property_not_supported :
|
73
|
+
property_not_supported :technical_contact
|
74
74
|
|
75
75
|
|
76
76
|
property_not_supported :nameservers
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#
|
2
|
+
# = Ruby Whois
|
3
|
+
#
|
4
|
+
# An intelligent pure Ruby WHOIS client and parser.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# Category:: Net
|
8
|
+
# Package:: Whois
|
9
|
+
# Author:: Simone Carletti <weppos@weppos.net>
|
10
|
+
# License:: MIT License
|
11
|
+
#
|
12
|
+
#--
|
13
|
+
#
|
14
|
+
#++
|
15
|
+
|
16
|
+
|
17
|
+
require 'whois/answer/parser/base'
|
18
|
+
|
19
|
+
|
20
|
+
module Whois
|
21
|
+
class Answer
|
22
|
+
class Parser
|
23
|
+
|
24
|
+
#
|
25
|
+
# = whois.nic.am parser
|
26
|
+
#
|
27
|
+
# Parser for the whois.nic.am server.
|
28
|
+
#
|
29
|
+
# NOTE: This parser is just a stub and provides only a few basic methods
|
30
|
+
# to check for domain availability and get domain status.
|
31
|
+
# Please consider to contribute implementing missing methods.
|
32
|
+
# See WhoisNicIt parser for an explanation of all available methods
|
33
|
+
# and examples.
|
34
|
+
#
|
35
|
+
class WhoisNicAm < Base
|
36
|
+
|
37
|
+
property_supported :status do
|
38
|
+
@status ||= if content_for_scanner =~ /\s+Status:\s+(.*)\n/
|
39
|
+
$1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
property_supported :available? do
|
44
|
+
@available ||= !!(content_for_scanner =~ /No match/)
|
45
|
+
end
|
46
|
+
|
47
|
+
property_supported :registered? do
|
48
|
+
!available?
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
property_supported :created_on do
|
53
|
+
@created_on ||= if content_for_scanner =~ /\s+Registered:\s+(.*)\n/
|
54
|
+
Time.parse($1)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
property_supported :updated_on do
|
59
|
+
@updated_on ||= if content_for_scanner =~ /\s+Last modified:\s+(.*)\n/
|
60
|
+
Time.parse($1)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
property_supported :expires_on do
|
65
|
+
@expires_on ||= if content_for_scanner =~ /\s+Expires:\s+(.*)\n/
|
66
|
+
Time.parse($1)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
property_supported :nameservers do
|
72
|
+
@nameservers ||= if content_for_scanner =~ /DNS servers:\n((.+\n)+)\n/
|
73
|
+
$1.split("\n").map { |value| value.strip }
|
74
|
+
else
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#
|
2
|
+
# = Ruby Whois
|
3
|
+
#
|
4
|
+
# An intelligent pure Ruby WHOIS client and parser.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# Category:: Net
|
8
|
+
# Package:: Whois
|
9
|
+
# Author:: Simone Carletti <weppos@weppos.net>
|
10
|
+
# License:: MIT License
|
11
|
+
#
|
12
|
+
#--
|
13
|
+
#
|
14
|
+
#++
|
15
|
+
|
16
|
+
|
17
|
+
require 'whois/answer/parser/base'
|
18
|
+
|
19
|
+
|
20
|
+
module Whois
|
21
|
+
class Answer
|
22
|
+
class Parser
|
23
|
+
|
24
|
+
#
|
25
|
+
# = whois.nic.as parser
|
26
|
+
#
|
27
|
+
# Parser for the whois.nic.as server.
|
28
|
+
#
|
29
|
+
# NOTE: This parser is just a stub and provides only a few basic methods
|
30
|
+
# to check for domain availability and get domain status.
|
31
|
+
# Please consider to contribute implementing missing methods.
|
32
|
+
# See WhoisNicIt parser for an explanation of all available methods
|
33
|
+
# and examples.
|
34
|
+
#
|
35
|
+
class WhoisNicAs < Base
|
36
|
+
|
37
|
+
property_supported :status do
|
38
|
+
@status ||= if available?
|
39
|
+
:available
|
40
|
+
else
|
41
|
+
:registered
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
property_supported :available? do
|
46
|
+
@available ||= !!(content_for_scanner =~ /Domain Not Found/)
|
47
|
+
end
|
48
|
+
|
49
|
+
property_supported :registered? do
|
50
|
+
!available?
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
property_not_supported :created_on
|
55
|
+
|
56
|
+
property_not_supported :updated_on
|
57
|
+
|
58
|
+
property_not_supported :expires_on
|
59
|
+
|
60
|
+
|
61
|
+
property_supported :nameservers do
|
62
|
+
@nameservers ||= if content_for_scanner =~ /Nameservers:\s((.+\n)+)\n/
|
63
|
+
$1.split("\n").map { |value| value.strip.split(" ").first }.compact
|
64
|
+
else
|
65
|
+
[]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -83,13 +83,13 @@ module Whois
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
property_supported :
|
86
|
+
property_supported :registrant_contact do
|
87
87
|
return unless registered?
|
88
|
-
return @
|
88
|
+
return @registrant_contact if @registrant_contact
|
89
89
|
|
90
90
|
address, city, zip, country_code = decompose_address(node('address'))
|
91
91
|
|
92
|
-
@
|
92
|
+
@registrant_contact = Answer::Contact.new(
|
93
93
|
:name => node('name'),
|
94
94
|
:organization => node('org'),
|
95
95
|
:address => address,
|
@@ -101,12 +101,12 @@ module Whois
|
|
101
101
|
)
|
102
102
|
end
|
103
103
|
|
104
|
-
property_supported :
|
105
|
-
contact('admin-c')
|
104
|
+
property_supported :admin_contact do
|
105
|
+
@admin_contact ||= contact('admin-c')
|
106
106
|
end
|
107
107
|
|
108
|
-
property_supported :
|
109
|
-
contact('tech-c')
|
108
|
+
property_supported :technical_contact do
|
109
|
+
@tecnical_contact ||= contact('tech-c')
|
110
110
|
end
|
111
111
|
|
112
112
|
|
@@ -94,20 +94,20 @@ module Whois
|
|
94
94
|
|
95
95
|
# If available, returns a <tt>Whois::Answer::Contact</tt> record
|
96
96
|
# containing the registrant details extracted from the registry answer.
|
97
|
-
property_supported :
|
98
|
-
contact("Registrant")
|
97
|
+
property_supported :registrant_contact do
|
98
|
+
@registrant_contact ||= contact("Registrant")
|
99
99
|
end
|
100
100
|
|
101
101
|
# If available, returns a <tt>Whois::Answer::Contact</tt> record
|
102
102
|
# containing the admin contact details extracted from the registry answer.
|
103
|
-
property_supported :
|
104
|
-
contact("Admin Contact")
|
103
|
+
property_supported :admin_contact do
|
104
|
+
@admin_contact ||= contact("Admin Contact")
|
105
105
|
end
|
106
106
|
|
107
107
|
# If available, returns a <tt>Whois::Answer::Contact</tt> record
|
108
108
|
# containing the technical contact details extracted from the registry answer.
|
109
|
-
property_supported :
|
110
|
-
contact("Technical Contacts")
|
109
|
+
property_supported :technical_contact do
|
110
|
+
@technical_contact ||= contact("Technical Contacts")
|
111
111
|
end
|
112
112
|
|
113
113
|
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#
|
2
|
+
# = Ruby Whois
|
3
|
+
#
|
4
|
+
# An intelligent pure Ruby WHOIS client and parser.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# Category:: Net
|
8
|
+
# Package:: Whois
|
9
|
+
# Author:: Simone Carletti <weppos@weppos.net>
|
10
|
+
# License:: MIT License
|
11
|
+
#
|
12
|
+
#--
|
13
|
+
#
|
14
|
+
#++
|
15
|
+
|
16
|
+
|
17
|
+
require 'whois/answer/parser/base'
|
18
|
+
|
19
|
+
|
20
|
+
module Whois
|
21
|
+
class Answer
|
22
|
+
class Parser
|
23
|
+
|
24
|
+
#
|
25
|
+
# = whois.nic.st parser
|
26
|
+
#
|
27
|
+
# Parser for the whois.nic.st server.
|
28
|
+
#
|
29
|
+
# NOTE: This parser is just a stub and provides only a few basic methods
|
30
|
+
# to check for domain availability and get domain status.
|
31
|
+
# Please consider to contribute implementing missing methods.
|
32
|
+
# See WhoisNicIt parser for an explanation of all available methods
|
33
|
+
# and examples.
|
34
|
+
#
|
35
|
+
class WhoisNicSt < Base
|
36
|
+
|
37
|
+
property_supported :status do
|
38
|
+
@status ||= if available?
|
39
|
+
:available
|
40
|
+
else
|
41
|
+
:registered
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
property_supported :available? do
|
46
|
+
@available ||= !!(content_for_scanner =~ /No entries found for domain/)
|
47
|
+
end
|
48
|
+
|
49
|
+
property_supported :registered? do
|
50
|
+
!available?
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
property_supported :created_on do
|
55
|
+
@created_on ||= if content_for_scanner =~ /\s+Creation Date:\s+(.*)\n/
|
56
|
+
Time.parse($1)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
property_supported :updated_on do
|
61
|
+
@updated_on ||= if content_for_scanner =~ /\s+Updated Date:\s+(.*)\n/
|
62
|
+
Time.parse($1)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
property_not_supported :expires_on
|
67
|
+
|
68
|
+
|
69
|
+
property_supported :nameservers do
|
70
|
+
@nameservers ||= if content_for_scanner =~ /Name Servers:\n((.+\n)+)\n?/
|
71
|
+
$1.split("\n").map(&:strip)
|
72
|
+
else
|
73
|
+
[]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -83,15 +83,15 @@ module Whois
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
property_supported :
|
86
|
+
property_supported :registrant_contact do
|
87
87
|
contact("Registrant")
|
88
88
|
end
|
89
89
|
|
90
|
-
property_supported :
|
90
|
+
property_supported :admin_contact do
|
91
91
|
contact("Admin")
|
92
92
|
end
|
93
93
|
|
94
|
-
property_supported :
|
94
|
+
property_supported :technical_contact do
|
95
95
|
contact("Tech")
|
96
96
|
end
|
97
97
|
|
data/lib/whois/version.rb
CHANGED
@@ -45,6 +45,24 @@ class AnswerParserBaseTest < Test::Unit::TestCase
|
|
45
45
|
end
|
46
46
|
|
47
47
|
|
48
|
+
def test_contacts_should_return_empty_array_with_all_unsupported
|
49
|
+
parser = @klass.new(@part)
|
50
|
+
assert_equal [], parser.contacts
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_contacts_should_return_all_supported_contacts
|
54
|
+
c1 = "1st"
|
55
|
+
c2 = "2nd"
|
56
|
+
c3 = "3rd"
|
57
|
+
klass = Class.new(@klass) do
|
58
|
+
register_property(:registrant_contact, :supported) { [c1, c2] }
|
59
|
+
register_property(:admin_contact, :supported) { nil }
|
60
|
+
register_property(:technical_contact, :supported) { c3 }
|
61
|
+
end
|
62
|
+
assert_equal [c1, c2, c3], klass.new(@part).contacts
|
63
|
+
end
|
64
|
+
|
65
|
+
|
48
66
|
def test_self_property_registry
|
49
67
|
assert_instance_of Hash, @klass.property_registry
|
50
68
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'whois/answer/parser/whois.ausregistry.net.au'
|
3
|
+
|
4
|
+
class AnswerParserWhoisAusregistryNetAuTest < Whois::Answer::Parser::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@klass = Whois::Answer::Parser::WhoisAusregistryNetAu
|
8
|
+
@host = "whois.ausregistry.net.au"
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def test_status
|
13
|
+
parser = @klass.new(load_part('/registered.txt'))
|
14
|
+
expected = "ok"
|
15
|
+
assert_equal expected, parser.status
|
16
|
+
assert_equal expected, parser.instance_eval { @status }
|
17
|
+
|
18
|
+
parser = @klass.new(load_part('/available.txt'))
|
19
|
+
expected = nil
|
20
|
+
assert_equal expected, parser.status
|
21
|
+
assert_equal expected, parser.instance_eval { @status }
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_available?
|
25
|
+
assert !@klass.new(load_part('/registered.txt')).available?
|
26
|
+
assert @klass.new(load_part('/available.txt')).available?
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_registered?
|
30
|
+
assert @klass.new(load_part('/registered.txt')).registered?
|
31
|
+
assert !@klass.new(load_part('/available.txt')).registered?
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def test_created_on
|
36
|
+
assert_raise(Whois::PropertyNotSupported) { @klass.new(load_part('/registered.txt')).created_on }
|
37
|
+
assert_raise(Whois::PropertyNotSupported) { @klass.new(load_part('/available.txt')).created_on }
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_updated_on
|
41
|
+
parser = @klass.new(load_part('/registered.txt'))
|
42
|
+
expected = Time.parse("2009-10-12 16:05:44 UTC")
|
43
|
+
assert_equal expected, parser.updated_on
|
44
|
+
assert_equal expected, parser.instance_eval { @updated_on }
|
45
|
+
|
46
|
+
parser = @klass.new(load_part('/available.txt'))
|
47
|
+
expected = nil
|
48
|
+
assert_equal expected, parser.updated_on
|
49
|
+
assert_equal expected, parser.instance_eval { @updated_on }
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_expires_on
|
53
|
+
assert_raise(Whois::PropertyNotSupported) { @klass.new(load_part('/registered.txt')).expires_on }
|
54
|
+
assert_raise(Whois::PropertyNotSupported) { @klass.new(load_part('/available.txt')).expires_on }
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def test_nameservers
|
59
|
+
parser = @klass.new(load_part('/registered.txt'))
|
60
|
+
expected = %w( ns1.google.com ns2.google.com ns3.google.com ns4.google.com )
|
61
|
+
assert_equal expected, parser.nameservers
|
62
|
+
assert_equal expected, parser.instance_eval { @nameservers }
|
63
|
+
|
64
|
+
parser = @klass.new(load_part('/available.txt'))
|
65
|
+
expected = %w()
|
66
|
+
assert_equal expected, parser.nameservers
|
67
|
+
assert_equal expected, parser.instance_eval { @nameservers }
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|