whois 2.7.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +143 -0
- data/{LICENSE → LICENSE.txt} +1 -1
- data/README.md +28 -41
- data/bin/ruby-whois +14 -7
- data/data/ipv4.json +723 -0
- data/data/ipv6.json +100 -0
- data/data/tld.json +1302 -0
- data/lib/whois.rb +3 -3
- data/lib/whois/client.rb +17 -7
- data/lib/whois/core_ext.rb +0 -2
- data/lib/whois/errors.rb +13 -20
- data/lib/whois/record.rb +28 -22
- data/lib/whois/record/contact.rb +1 -1
- data/lib/whois/record/nameserver.rb +1 -1
- data/lib/whois/record/parser.rb +70 -46
- data/lib/whois/record/parser/base.rb +58 -59
- data/lib/whois/record/parser/base_afilias.rb +2 -7
- data/lib/whois/record/parser/base_cocca.rb +8 -5
- data/lib/whois/record/parser/base_cocca2.rb +107 -0
- data/lib/whois/record/parser/base_shared1.rb +2 -7
- data/lib/whois/record/parser/base_shared2.rb +2 -7
- data/lib/whois/record/parser/base_whoisd.rb +16 -9
- data/lib/whois/record/parser/blank.rb +1 -1
- data/lib/whois/record/parser/example.rb +1 -10
- data/lib/whois/record/parser/jobswhois.verisign-grs.com.rb +19 -19
- data/lib/whois/record/parser/kero.yachay.pe.rb +28 -18
- data/lib/whois/record/parser/whois.adamsnames.tc.rb +1 -1
- data/lib/whois/record/parser/whois.aeda.net.ae.rb +1 -1
- data/lib/whois/record/parser/whois.aero.rb +2 -2
- data/lib/whois/record/parser/whois.afilias-grs.info.rb +1 -1
- data/lib/whois/record/parser/whois.afilias.info.rb +1 -1
- data/lib/whois/record/parser/whois.ai.rb +1 -1
- data/lib/whois/record/parser/whois.arnes.si.rb +1 -1
- data/lib/whois/record/parser/whois.ati.tn.rb +3 -8
- data/lib/whois/record/parser/whois.audns.net.au.rb +4 -9
- data/lib/whois/record/parser/whois.ax.rb +66 -0
- data/lib/whois/record/parser/whois.biz.rb +1 -1
- data/lib/whois/record/parser/whois.cat.rb +1 -1
- data/lib/whois/record/parser/whois.cctld.by.rb +5 -8
- data/lib/whois/record/parser/whois.cctld.uz.rb +1 -1
- data/lib/whois/record/parser/whois.centralnic.com.rb +4 -9
- data/lib/whois/record/parser/whois.cira.ca.rb +3 -8
- data/lib/whois/record/parser/whois.cmc.iq.rb +7 -4
- data/lib/whois/record/parser/whois.cnnic.cn.rb +13 -21
- data/lib/whois/record/parser/whois.co.ca.rb +1 -1
- data/lib/whois/record/parser/whois.co.pl.rb +1 -6
- data/lib/whois/record/parser/whois.co.ug.rb +2 -2
- data/lib/whois/record/parser/whois.crsnic.net.rb +14 -15
- data/lib/whois/record/parser/whois.denic.de.rb +2 -2
- data/lib/whois/record/parser/whois.dk-hostmaster.dk.rb +2 -2
- data/lib/whois/record/parser/whois.dns.be.rb +2 -2
- data/lib/whois/record/parser/whois.dns.hr.rb +3 -8
- data/lib/whois/record/parser/whois.dns.lu.rb +1 -1
- data/lib/whois/record/parser/whois.dns.pl.rb +70 -9
- data/lib/whois/record/parser/whois.dns.pt.rb +16 -15
- data/lib/whois/record/parser/whois.domain-registry.nl.rb +2 -2
- data/lib/whois/record/parser/whois.domain.kg.rb +1 -1
- data/lib/whois/record/parser/whois.domainregistry.ie.rb +9 -12
- data/lib/whois/record/parser/whois.domainregistry.my.rb +1 -1
- data/lib/whois/record/parser/whois.domreg.lt.rb +1 -1
- data/lib/whois/record/parser/whois.dot.tk.rb +1 -1
- data/lib/whois/record/parser/whois.dotmobiregistry.net.rb +1 -1
- data/lib/whois/record/parser/whois.dreamhost.com.rb +1 -1
- data/lib/whois/record/parser/whois.educause.edu.rb +1 -6
- data/lib/whois/record/parser/whois.eenet.ee.rb +1 -1
- data/lib/whois/record/parser/whois.enom.com.rb +1 -1
- data/lib/whois/record/parser/whois.eu.org.rb +1 -1
- data/lib/whois/record/parser/whois.eu.rb +13 -1
- data/lib/whois/record/parser/whois.fi.rb +2 -2
- data/lib/whois/record/parser/whois.gg.rb +1 -1
- data/lib/whois/record/parser/whois.godaddy.com.rb +4 -4
- data/lib/whois/record/parser/whois.gov.za.rb +1 -1
- data/lib/whois/record/parser/whois.hkirc.hk.rb +1 -1
- data/lib/whois/record/parser/whois.iam.net.ma.rb +1 -1
- data/lib/whois/record/parser/whois.iana.org.rb +2 -2
- data/lib/whois/record/parser/whois.in.ua.rb +1 -1
- data/lib/whois/record/parser/whois.isnic.is.rb +1 -1
- data/lib/whois/record/parser/whois.isoc.org.il.rb +1 -1
- data/lib/whois/record/parser/whois.ja.net.rb +1 -1
- data/lib/whois/record/parser/whois.je.rb +1 -1
- data/lib/whois/record/parser/whois.jprs.jp.rb +9 -6
- data/lib/whois/record/parser/whois.kenic.or.ke.rb +1 -1
- data/lib/whois/record/parser/whois.kr.rb +1 -1
- data/lib/whois/record/parser/whois.markmonitor.com.rb +1 -1
- data/lib/whois/record/parser/whois.meregistry.net.rb +1 -1
- data/lib/whois/record/parser/whois.monic.mo.rb +1 -6
- data/lib/whois/record/parser/whois.museum.rb +1 -1
- data/lib/whois/record/parser/whois.na-nic.com.na.rb +3 -23
- data/lib/whois/record/parser/whois.nc.rb +8 -11
- data/lib/whois/record/parser/whois.netcom.cm.rb +1 -1
- data/lib/whois/record/parser/whois.networksolutions.com.rb +1 -1
- data/lib/whois/record/parser/whois.nic-se.se.rb +1 -1
- data/lib/whois/record/parser/whois.nic.ac.rb +1 -6
- data/lib/whois/record/parser/whois.nic.af.rb +7 -3
- data/lib/whois/record/parser/whois.nic.ag.rb +1 -1
- data/lib/whois/record/parser/whois.nic.am.rb +1 -1
- data/lib/whois/record/parser/whois.nic.as.rb +1 -1
- data/lib/whois/record/parser/whois.nic.asia.rb +1 -1
- data/lib/whois/record/parser/whois.nic.at.rb +7 -9
- data/lib/whois/record/parser/whois.nic.bo.rb +1 -1
- data/lib/whois/record/parser/whois.nic.cc.rb +11 -11
- data/lib/whois/record/parser/whois.nic.cd.rb +1 -1
- data/lib/whois/record/parser/whois.nic.ch.rb +1 -1
- data/lib/whois/record/parser/whois.nic.ci.rb +1 -1
- data/lib/whois/record/parser/whois.nic.ck.rb +1 -1
- data/lib/whois/record/parser/whois.nic.cl.rb +1 -1
- data/lib/whois/record/parser/whois.nic.co.rb +1 -1
- data/lib/whois/record/parser/whois.nic.coop.rb +1 -1
- data/lib/whois/record/parser/whois.nic.cx.rb +7 -3
- data/lib/whois/record/parser/whois.nic.cz.rb +8 -3
- data/lib/whois/record/parser/whois.nic.dm.rb +3 -8
- data/lib/whois/record/parser/whois.nic.dz.rb +1 -1
- data/lib/whois/record/parser/whois.nic.ec.rb +1 -1
- data/lib/whois/record/parser/whois.nic.fo.rb +2 -2
- data/lib/whois/record/parser/whois.nic.fr.rb +1 -1
- data/lib/whois/record/parser/whois.nic.gl.rb +5 -1
- data/lib/whois/record/parser/whois.nic.gov.rb +11 -12
- data/lib/whois/record/parser/whois.nic.gs.rb +7 -23
- data/lib/whois/record/parser/whois.nic.hn.rb +28 -0
- data/lib/whois/record/parser/whois.nic.ht.rb +7 -3
- data/lib/whois/record/parser/whois.nic.hu.rb +2 -2
- data/lib/whois/record/parser/whois.nic.im.rb +1 -1
- data/lib/whois/record/parser/whois.nic.io.rb +1 -6
- data/lib/whois/record/parser/whois.nic.ir.rb +1 -1
- data/lib/whois/record/parser/whois.nic.it.rb +2 -7
- data/lib/whois/record/parser/whois.nic.ki.rb +7 -3
- data/lib/whois/record/parser/whois.nic.kz.rb +9 -12
- data/lib/whois/record/parser/whois.nic.la.rb +3 -2
- data/lib/whois/record/parser/whois.nic.li.rb +1 -1
- data/lib/whois/record/parser/whois.nic.lk.rb +3 -9
- data/lib/whois/record/parser/whois.nic.lv.rb +1 -1
- data/lib/whois/record/parser/whois.nic.ly.rb +1 -1
- data/lib/whois/record/parser/whois.nic.md.rb +1 -6
- data/lib/whois/record/parser/whois.nic.mg.rb +1 -1
- data/lib/whois/record/parser/whois.nic.ms.rb +7 -3
- data/lib/whois/record/parser/whois.nic.mu.rb +7 -3
- data/lib/whois/record/parser/whois.nic.mx.rb +1 -1
- data/lib/whois/record/parser/whois.nic.name.rb +2 -2
- data/lib/whois/record/parser/whois.nic.net.nf.rb +7 -42
- data/lib/whois/record/parser/whois.nic.net.ng.rb +3 -3
- data/lib/whois/record/parser/whois.nic.net.sa.rb +1 -1
- data/lib/whois/record/parser/whois.nic.net.sb.rb +7 -3
- data/lib/whois/record/parser/whois.nic.nu.rb +1 -1
- data/lib/whois/record/parser/whois.nic.org.uy.rb +1 -1
- data/lib/whois/record/parser/whois.nic.pr.rb +32 -14
- data/lib/whois/record/parser/whois.nic.priv.at.rb +1 -1
- data/lib/whois/record/parser/whois.nic.pw.rb +27 -0
- data/lib/whois/record/parser/whois.nic.sh.rb +1 -6
- data/lib/whois/record/parser/whois.nic.sl.rb +1 -1
- data/lib/whois/record/parser/whois.nic.sm.rb +1 -1
- data/lib/whois/record/parser/whois.nic.sn.rb +1 -6
- data/lib/whois/record/parser/whois.nic.so.rb +1 -1
- data/lib/whois/record/parser/whois.nic.st.rb +1 -1
- data/lib/whois/record/parser/whois.nic.tel.rb +5 -54
- data/lib/whois/record/parser/whois.nic.tl.rb +7 -3
- data/lib/whois/record/parser/whois.nic.tm.rb +1 -6
- data/lib/whois/record/parser/whois.nic.tr.rb +1 -1
- data/lib/whois/record/parser/whois.nic.travel.rb +5 -50
- data/lib/whois/record/parser/whois.nic.tv.rb +11 -12
- data/lib/whois/record/parser/whois.nic.uk.rb +18 -20
- data/lib/whois/record/parser/whois.nic.us.rb +5 -50
- data/lib/whois/record/parser/whois.nic.ve.rb +1 -1
- data/lib/whois/record/parser/whois.nic.xxx.rb +1 -1
- data/lib/whois/record/parser/whois.norid.no.rb +1 -1
- data/lib/whois/record/parser/whois.org.za.rb +1 -6
- data/lib/whois/record/parser/whois.pandi.or.id.rb +1 -1
- data/lib/whois/record/parser/whois.pir.org.rb +1 -1
- data/lib/whois/record/parser/whois.pnina.ps.rb +1 -1
- data/lib/whois/record/parser/whois.register.bg.rb +1 -1
- data/lib/whois/record/parser/whois.register.com.rb +2 -2
- data/lib/whois/record/parser/whois.registro.br.rb +1 -1
- data/lib/whois/record/parser/whois.registry.gy.rb +7 -3
- data/lib/whois/record/parser/whois.registry.hm.rb +1 -1
- data/lib/whois/record/parser/whois.registry.in.rb +1 -1
- data/lib/whois/record/parser/whois.registry.net.za.rb +123 -0
- data/lib/whois/record/parser/whois.registry.om.rb +2 -2
- data/lib/whois/record/parser/whois.registry.qa.rb +1 -1
- data/lib/whois/record/parser/whois.registrypro.pro.rb +2 -2
- data/lib/whois/record/parser/whois.ripe.net.rb +1 -1
- data/lib/whois/record/parser/whois.rnids.rs.rb +3 -8
- data/lib/whois/record/parser/whois.rotld.ro.rb +1 -1
- data/lib/whois/record/parser/whois.samoanic.ws.rb +1 -1
- data/lib/whois/record/parser/whois.sgnic.sg.rb +1 -1
- data/lib/whois/record/parser/whois.sk-nic.sk.rb +1 -1
- data/lib/whois/record/parser/whois.smallregistry.net.rb +2 -2
- data/lib/whois/record/parser/whois.srs.net.nz.rb +1 -1
- data/lib/whois/record/parser/whois.sx.rb +50 -32
- data/lib/whois/record/parser/whois.tcinet.ru.rb +2 -2
- data/lib/whois/record/parser/whois.thnic.co.th.rb +5 -5
- data/lib/whois/record/parser/whois.tld.ee.rb +2 -2
- data/lib/whois/record/parser/whois.tonic.to.rb +1 -6
- data/lib/whois/record/parser/whois.twnic.net.tw.rb +1 -1
- data/lib/whois/record/parser/whois.tznic.or.tz.rb +2 -2
- data/lib/whois/record/parser/whois.ua.rb +1 -6
- data/lib/whois/record/parser/whois.usp.ac.fj.rb +1 -1
- data/lib/whois/record/parser/whois.za.net.rb +1 -1
- data/lib/whois/record/parser/whois.za.org.rb +1 -1
- data/lib/whois/record/parser/whois1.nic.bi.rb +5 -1
- data/lib/whois/record/part.rb +1 -1
- data/lib/whois/record/registrar.rb +1 -1
- data/lib/whois/record/scanners/base.rb +1 -1
- data/lib/whois/record/scanners/base_afilias.rb +1 -1
- data/lib/whois/record/scanners/base_shared1.rb +1 -1
- data/lib/whois/record/scanners/base_shared2.rb +1 -2
- data/lib/whois/record/scanners/base_whoisd.rb +4 -4
- data/lib/whois/record/scanners/iana.rb +1 -1
- data/lib/whois/record/scanners/{ast.rb → nodable.rb} +4 -4
- data/lib/whois/record/scanners/verisign.rb +1 -1
- data/lib/whois/record/scanners/whois.ati.tn.rb +1 -1
- data/lib/whois/record/scanners/whois.audns.net.au.rb +1 -1
- data/lib/whois/record/scanners/whois.cctld.by.rb +3 -1
- data/lib/whois/record/scanners/whois.centralnic.com.rb +1 -1
- data/lib/whois/record/scanners/whois.cira.ca.rb +1 -1
- data/lib/whois/record/scanners/whois.cnnic.cn.rb +6 -3
- data/lib/whois/record/scanners/whois.denic.de.rb +1 -1
- data/lib/whois/record/scanners/whois.dns.hr.rb +1 -1
- data/lib/whois/record/scanners/whois.domainregistry.ie.rb +3 -1
- data/lib/whois/record/scanners/whois.nc.rb +1 -1
- data/lib/whois/record/scanners/whois.nic.dm.rb +1 -1
- data/lib/whois/record/scanners/whois.nic.hu.rb +1 -1
- data/lib/whois/record/scanners/whois.nic.it.rb +1 -1
- data/lib/whois/record/scanners/whois.registry.net.za.rb +103 -0
- data/lib/whois/record/scanners/whois.rnids.rs.rb +1 -1
- data/lib/whois/record/scanners/whois.smallregistry.net.rb +1 -1
- data/lib/whois/record/scanners/whois.sx.rb +14 -46
- data/lib/whois/record/super_struct.rb +1 -1
- data/lib/whois/server.rb +18 -4
- data/lib/whois/server/adapters/afilias.rb +8 -13
- data/lib/whois/server/adapters/arpa.rb +1 -1
- data/lib/whois/server/adapters/base.rb +24 -44
- data/lib/whois/server/adapters/formatted.rb +1 -1
- data/lib/whois/server/adapters/none.rb +1 -1
- data/lib/whois/server/adapters/not_implemented.rb +1 -1
- data/lib/whois/server/adapters/standard.rb +1 -1
- data/lib/whois/server/adapters/verisign.rb +11 -19
- data/lib/whois/server/adapters/web.rb +2 -5
- data/lib/whois/server/socket_handler.rb +66 -0
- data/lib/whois/version.rb +3 -3
- data/whois.gemspec +11 -11
- metadata +24 -29
- data/lib/whois/core_ext/date_time/conversions.rb +0 -14
- data/lib/whois/definitions/ipv4.rb +0 -240
- data/lib/whois/definitions/ipv6.rb +0 -32
- data/lib/whois/definitions/tlds.rb +0 -367
- data/lib/whois/record/parser/saudinic.net.sa.rb +0 -23
- data/lib/whois/record/parser/whois.ausregistry.net.au.rb +0 -23
- data/lib/whois/record/parser/whois.centralnic.net.rb +0 -25
- data/lib/whois/record/parser/whois.cnnic.net.cn.rb +0 -23
- data/lib/whois/record/parser/whois.coza.net.za.rb +0 -76
- data/lib/whois/record/parser/whois.ficora.fi.rb +0 -24
- data/lib/whois/record/parser/whois.hkdnr.net.hk.rb +0 -23
- data/lib/whois/record/parser/whois.net.ua.rb +0 -24
- data/lib/whois/record/parser/whois.nic.or.kr.rb +0 -24
- data/lib/whois/record/parser/whois.publicinterestregistry.net.rb +0 -23
- data/lib/whois/record/parser/whois.ripn.net.rb +0 -23
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
5
|
#
|
6
|
-
# Copyright (c) 2009-
|
6
|
+
# Copyright (c) 2009-2013 Simone Carletti <weppos@weppos.net>
|
7
7
|
#++
|
8
8
|
|
9
9
|
|
@@ -14,63 +14,31 @@ module Whois
|
|
14
14
|
class Record
|
15
15
|
module Scanners
|
16
16
|
|
17
|
-
# Scanner for the whois.sx record.
|
18
|
-
#
|
19
|
-
# @since 2.6.2
|
20
17
|
class WhoisSx < Base
|
21
18
|
|
22
19
|
self.tokenizers += [
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:skip_empty_line,
|
26
|
-
:flag_section_start,
|
27
|
-
:flag_section_end,
|
28
|
-
:scan_section,
|
20
|
+
:skip_blank_line,
|
21
|
+
:scan_available,
|
29
22
|
:scan_keyvalue,
|
23
|
+
:skip_lastupdate,
|
24
|
+
:scan_disclaimer,
|
30
25
|
]
|
31
26
|
|
32
27
|
|
33
|
-
tokenizer :
|
34
|
-
if @input.
|
35
|
-
@input
|
28
|
+
tokenizer :scan_available do
|
29
|
+
if @input.scan(/^Status: (.+) \(No match for domain "(.+)"\)\n/)
|
30
|
+
@ast["Domain Status"] = @input[1]
|
31
|
+
@ast["Domain Name"] = @input[2]
|
36
32
|
end
|
37
33
|
end
|
38
34
|
|
39
|
-
tokenizer :
|
40
|
-
|
41
|
-
@input.skip_until(/\n/)
|
42
|
-
end
|
35
|
+
tokenizer :skip_lastupdate do
|
36
|
+
@input.skip(/>>>(.+?)<<<\n/)
|
43
37
|
end
|
44
38
|
|
45
|
-
tokenizer :
|
46
|
-
if @input.
|
47
|
-
@
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
tokenizer :flag_section_end do
|
52
|
-
# if @input.match?(/^\n/)
|
53
|
-
# @tmp.delete('section')
|
54
|
-
# end
|
55
|
-
end
|
56
|
-
|
57
|
-
tokenizer :scan_section do
|
58
|
-
if @tmp['section']
|
59
|
-
lines = _scan_lines_to_array(/^(.+)\n/)
|
60
|
-
|
61
|
-
# Check all lines to be sure there is no case where a value containing a :
|
62
|
-
# is misinterpreted as key : value.
|
63
|
-
|
64
|
-
# The section is a hash
|
65
|
-
value = if lines.all? { |line| line.index(':', 1) }
|
66
|
-
Hash[lines.map { |line| line.split(':', 2).map(&:strip) }]
|
67
|
-
# The section is an array of values
|
68
|
-
else
|
69
|
-
lines
|
70
|
-
end
|
71
|
-
|
72
|
-
@ast[@tmp['section']] = value
|
73
|
-
@tmp.delete('section')
|
39
|
+
tokenizer :scan_disclaimer do
|
40
|
+
if @input.match?(/^% WHOIS LEGAL STATEMENT/)
|
41
|
+
@ast["field:disclaimer"] = _scan_lines_to_array(/%(.*)\n/).map(&:strip).join("\n")
|
74
42
|
end
|
75
43
|
end
|
76
44
|
|
data/lib/whois/server.rb
CHANGED
@@ -3,11 +3,13 @@
|
|
3
3
|
#
|
4
4
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
5
|
#
|
6
|
-
# Copyright (c) 2009-
|
6
|
+
# Copyright (c) 2009-2013 Simone Carletti <weppos@weppos.net>
|
7
7
|
#++
|
8
8
|
|
9
9
|
|
10
10
|
require 'ipaddr'
|
11
|
+
require 'json'
|
12
|
+
require 'whois/server/adapters/base'
|
11
13
|
|
12
14
|
|
13
15
|
module Whois
|
@@ -23,7 +25,6 @@ module Whois
|
|
23
25
|
# WHOIS server adapters. Each adapter is a subclass of {Whois::Server::Adapters::Base},
|
24
26
|
# customized to handle WHOIS queries for a type or a group of servers.
|
25
27
|
module Adapters
|
26
|
-
autoload :Base, "whois/server/adapters/base"
|
27
28
|
autoload :Arpa, "whois/server/adapters/arpa"
|
28
29
|
autoload :Afilias, "whois/server/adapters/afilias"
|
29
30
|
autoload :Formatted, "whois/server/adapters/formatted"
|
@@ -47,9 +48,22 @@ module Whois
|
|
47
48
|
#
|
48
49
|
# @return [void]
|
49
50
|
def self.load_definitions
|
50
|
-
Dir[File.
|
51
|
+
Dir[File.expand_path("../../../data/*.json", __FILE__)].each { |f| load_json(f) }
|
51
52
|
end
|
52
53
|
|
54
|
+
# Loads the definitions from a JSON file.
|
55
|
+
#
|
56
|
+
# @param [String] file The path to the definition file.
|
57
|
+
#
|
58
|
+
# @return [void]
|
59
|
+
def self.load_json(file)
|
60
|
+
type = File.basename(file, File.extname(file)).to_sym
|
61
|
+
JSON.load(File.read(file)).each do |allocation, settings|
|
62
|
+
define(type, allocation, settings.delete("host"), Hash[settings.map { |k,v| [k.to_sym, v] }])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
53
67
|
# Lookup and returns the definition list for given <tt>type</tt>,
|
54
68
|
# or all definitions if <tt>type</tt> is <tt>nil</tt>.
|
55
69
|
#
|
@@ -253,7 +267,7 @@ module Whois
|
|
253
267
|
return factory(type, *definition)
|
254
268
|
end
|
255
269
|
end
|
256
|
-
rescue ArgumentError
|
270
|
+
rescue ArgumentError
|
257
271
|
# continue
|
258
272
|
end
|
259
273
|
raise AllocationUnknown, "IP Allocation for `#{string}' unknown. Server definitions might be outdated."
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
5
|
#
|
6
|
-
# Copyright (c) 2009-
|
6
|
+
# Copyright (c) 2009-2013 Simone Carletti <weppos@weppos.net>
|
7
7
|
#++
|
8
8
|
|
9
9
|
|
@@ -16,11 +16,6 @@ module Whois
|
|
16
16
|
#
|
17
17
|
# Provides ability to query Afilias WHOIS interfaces.
|
18
18
|
#
|
19
|
-
# The following WHOIS servers are currently known
|
20
|
-
# to require the Afilias adapter:
|
21
|
-
#
|
22
|
-
# - whois.afilias-grs.info
|
23
|
-
#
|
24
19
|
class Afilias < Base
|
25
20
|
|
26
21
|
# Executes a WHOIS query to the Afilias WHOIS interface,
|
@@ -34,20 +29,20 @@ module Whois
|
|
34
29
|
response = query_the_socket(string, host)
|
35
30
|
buffer_append response, host
|
36
31
|
|
37
|
-
if
|
38
|
-
response = query_the_socket(string,
|
39
|
-
buffer_append
|
32
|
+
if options[:referral] != false && referral = extract_referral(response)
|
33
|
+
response = query_the_socket(string, referral)
|
34
|
+
buffer_append(response, referral)
|
40
35
|
end
|
41
36
|
end
|
42
37
|
|
43
38
|
|
44
39
|
private
|
45
40
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
41
|
+
def extract_referral(response)
|
42
|
+
if response =~ /Domain Name:/
|
43
|
+
response.slice(/Whois Server:(\S+)/, 1)
|
50
44
|
end
|
45
|
+
end
|
51
46
|
|
52
47
|
end
|
53
48
|
|
@@ -3,13 +3,13 @@
|
|
3
3
|
#
|
4
4
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
5
|
#
|
6
|
-
# Copyright (c) 2009-
|
6
|
+
# Copyright (c) 2009-2013 Simone Carletti <weppos@weppos.net>
|
7
7
|
#++
|
8
8
|
|
9
9
|
|
10
10
|
require 'whois/record/part'
|
11
11
|
require 'whois/record'
|
12
|
-
require '
|
12
|
+
require 'whois/server/socket_handler'
|
13
13
|
|
14
14
|
|
15
15
|
module Whois
|
@@ -20,20 +20,13 @@ module Whois
|
|
20
20
|
|
21
21
|
# Default WHOIS request port.
|
22
22
|
DEFAULT_WHOIS_PORT = 43
|
23
|
-
|
24
23
|
# Default bind hostname.
|
25
24
|
DEFAULT_BIND_HOST = "0.0.0.0"
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
Errno::ECONNRESET,
|
30
|
-
Errno::EHOSTUNREACH,
|
31
|
-
Errno::ECONNREFUSED,
|
32
|
-
SocketError,
|
33
|
-
]
|
34
|
-
|
26
|
+
class_attribute :query_handler
|
27
|
+
self.query_handler = SocketHandler.new
|
35
28
|
|
36
|
-
# @return [Symbol] The type of WHOIS server
|
29
|
+
# @return [Symbol] The type of WHOIS server.
|
37
30
|
attr_reader :type
|
38
31
|
# @return [String] The allocation this server is responsible for.
|
39
32
|
attr_reader :allocation
|
@@ -68,7 +61,6 @@ module Whois
|
|
68
61
|
# Checks self and other for equality.
|
69
62
|
#
|
70
63
|
# @param [The Whois::Server::Adapters::Base] other
|
71
|
-
#
|
72
64
|
# @return [Boolean] Returns true if the other is the same object,
|
73
65
|
# or <tt>other</tt> attributes matches this object attributes.
|
74
66
|
#
|
@@ -93,24 +85,24 @@ module Whois
|
|
93
85
|
# @return [Hash] The updated options for this object.
|
94
86
|
#
|
95
87
|
def configure(settings)
|
88
|
+
@host = settings[:host] if settings[:host]
|
96
89
|
options.merge!(settings)
|
97
90
|
end
|
98
91
|
|
99
92
|
|
100
|
-
# Performs a Whois
|
93
|
+
# Performs a Whois lookup for <tt>string</tt>
|
101
94
|
# using the current server adapter.
|
102
95
|
#
|
103
|
-
# @param [String] string The string to be sent as query parameter.
|
104
|
-
#
|
105
|
-
# @return [Whois::Record]
|
106
|
-
#
|
107
96
|
# Internally, this method calls {#request}
|
108
97
|
# using the Template Method design pattern.
|
109
98
|
#
|
110
|
-
# server.
|
99
|
+
# server.lookup("google.com")
|
111
100
|
# # => Whois::Record
|
112
101
|
#
|
113
|
-
|
102
|
+
# @param [String] string The string to be sent as query parameter.
|
103
|
+
# @return [Whois::Record]
|
104
|
+
#
|
105
|
+
def lookup(string)
|
114
106
|
buffer_start do |buffer|
|
115
107
|
request(string)
|
116
108
|
Whois::Record.new(self, buffer)
|
@@ -124,9 +116,8 @@ module Whois
|
|
124
116
|
# This is the heart of the Template Method design pattern.
|
125
117
|
#
|
126
118
|
# @param [String] string The string to be sent as query parameter.
|
127
|
-
#
|
128
|
-
# @raise [NotImplementedError]
|
129
119
|
# @return [void]
|
120
|
+
# @raise [NotImplementedError]
|
130
121
|
# @abstract
|
131
122
|
#
|
132
123
|
def request(string)
|
@@ -134,7 +125,7 @@ module Whois
|
|
134
125
|
end
|
135
126
|
|
136
127
|
|
137
|
-
|
128
|
+
private
|
138
129
|
|
139
130
|
# Store a record part in {#buffer}.
|
140
131
|
#
|
@@ -142,8 +133,6 @@ module Whois
|
|
142
133
|
# @param [String] host
|
143
134
|
# @return [void]
|
144
135
|
#
|
145
|
-
# @api public
|
146
|
-
#
|
147
136
|
def buffer_append(body, host)
|
148
137
|
@buffer << Whois::Record::Part.new(:body => body, :host => host)
|
149
138
|
end
|
@@ -156,8 +145,14 @@ module Whois
|
|
156
145
|
result
|
157
146
|
end
|
158
147
|
|
159
|
-
#
|
160
|
-
|
148
|
+
# Prepares and passes the query to the {#query_handler}.
|
149
|
+
#
|
150
|
+
# @param [String] query
|
151
|
+
# @param [String] host
|
152
|
+
# @param [String] port
|
153
|
+
# @return [String]
|
154
|
+
#
|
155
|
+
def query(query, host, port = nil)
|
161
156
|
args = []
|
162
157
|
args.push(host)
|
163
158
|
args.push(port || options[:port] || DEFAULT_WHOIS_PORT)
|
@@ -177,25 +172,10 @@ module Whois
|
|
177
172
|
args.push(options[:bind_port]) if options[:bind_port]
|
178
173
|
end
|
179
174
|
|
180
|
-
|
181
|
-
|
182
|
-
rescue *RESCUABLE_CONNECTION_ERRORS => error
|
183
|
-
raise ConnectionError, "#{error.class}: #{error.message}"
|
175
|
+
self.class.query_handler.call(query, *args)
|
184
176
|
end
|
185
177
|
|
186
|
-
|
187
|
-
# to the WHOIS server.
|
188
|
-
#
|
189
|
-
# This is for internal use only!
|
190
|
-
#
|
191
|
-
# @api private
|
192
|
-
def ask_the_socket(query, *args)
|
193
|
-
client = TCPSocket.new(*args)
|
194
|
-
client.write("#{query}\r\n") # I could use put(foo) and forget the \n
|
195
|
-
client.read # but write/read is more symmetric than puts/read
|
196
|
-
ensure # and I really want to use read instead of gets.
|
197
|
-
client.close if client # If != client something went wrong.
|
198
|
-
end
|
178
|
+
alias :query_the_socket :query
|
199
179
|
|
200
180
|
end
|
201
181
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
5
|
#
|
6
|
-
# Copyright (c) 2009-
|
6
|
+
# Copyright (c) 2009-2013 Simone Carletti <weppos@weppos.net>
|
7
7
|
#++
|
8
8
|
|
9
9
|
|
@@ -16,14 +16,6 @@ module Whois
|
|
16
16
|
#
|
17
17
|
# Provides ability to query Verisign WHOIS interfaces.
|
18
18
|
#
|
19
|
-
# The following WHOIS servers are currently known
|
20
|
-
# to require the Verisign adapter:
|
21
|
-
#
|
22
|
-
# - whois.nic.tv
|
23
|
-
# - whois.crsnic.net
|
24
|
-
# - jobswhois.verisign-grs.com
|
25
|
-
# - whois.nic.cc
|
26
|
-
#
|
27
19
|
class Verisign < Base
|
28
20
|
|
29
21
|
# Executes a WHOIS query to the Verisign WHOIS interface,
|
@@ -37,23 +29,23 @@ module Whois
|
|
37
29
|
response = query_the_socket("=#{string}", host)
|
38
30
|
buffer_append response, host
|
39
31
|
|
40
|
-
if
|
41
|
-
response = query_the_socket(string,
|
42
|
-
buffer_append
|
32
|
+
if options[:referral] != false && referral = extract_referral(response)
|
33
|
+
response = query_the_socket(string, referral)
|
34
|
+
buffer_append(response, referral)
|
43
35
|
end
|
44
36
|
end
|
45
37
|
|
46
38
|
|
47
39
|
private
|
48
40
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
41
|
+
def extract_referral(response)
|
42
|
+
if response =~ /Domain Name:/
|
43
|
+
server = response.scan(/Whois Server: (.+?)$/).flatten.last
|
44
|
+
server.strip! if server != nil
|
45
|
+
server = nil if server == "not defined"
|
46
|
+
server
|
56
47
|
end
|
48
|
+
end
|
57
49
|
|
58
50
|
end
|
59
51
|
|