forked from weppos/whois
/
whois.register.com.rb
122 lines (97 loc) · 3.11 KB
/
whois.register.com.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
# Copyright (c) 2012 SophosLabs http://www.sophos.com
#++
require 'whois/record/parser/base'
module Whois
class Record
class Parser
# Parser for the whois.register.com server.
#
# @see Whois::Record::Parser::Example
# The Example parser for the list of all available methods.
#
# @since 2.4.0
class WhoisRegisterCom < Base
property_not_supported :status
# The server is contacted only in case of a registered domain.
property_supported :available? do
false
end
property_supported :registered? do
!available?
end
property_supported :created_on do
if content_for_scanner =~ /Record created on (.+)\.\n/
Time.parse($1)
end
end
property_not_supported :updated_on
property_supported :expires_on do
if content_for_scanner =~ /Record expires on (.+)\.\n/
Time.parse($1)
end
end
property_supported :registrar do
Record::Registrar.new(
:name => "Register.com",
:organization => "REGISTER.COM, INC.",
:url => "www.register.com"
)
end
property_supported :registrant_contacts do
build_contact('Registrant:', Record::Contact::TYPE_REGISTRANT)
end
property_supported :admin_contacts do
build_contact('Administrative Contact:', Record::Contact::TYPE_ADMIN)
end
property_supported :technical_contacts do
build_contact('Technical\s+Contact:', Record::Contact::TYPE_TECHNICAL)
end
property_supported :nameservers do
if content_for_scanner =~ /DNS Servers:\n((?:\s*[^\s\n]+\n)+)/
$1.split("\n").map do |line|
Record::Nameserver.new(line.strip)
end
end
end
private
def build_contact(element, type)
match = content_for_scanner.slice(/#{element}\n((.+\n)+)\n/, 1)
return unless match
lines = match.split("\n").map(&:strip)
#Organization
#Name
#Address
#City, State Zip
#Country
#Phone: phone
#Email: email
organization = lines[0].strip
name = lines[1].strip
address = lines[2].strip
city, state, zip = lines[3].scan(/^(.+), ([A-Z]{2}) ([^\n]+)$/).first
phone = lines[5].split(':').last.strip
email = lines[6].split(':').last.strip
Record::Contact.new(
:type => type,
:name => name,
:organization => organization,
:address => address,
:city => city,
:state => state,
:zip => zip,
:country_code => lines[4],
:email => email,
:phone => phone,
:fax => nil
)
end
end
end
end
end