Skip to content
Browse files

Refactoring class to use an object oriented server definition. The li…

…st of servers is now automatically defined with a Ruby syntax instead of using YAML.
  • Loading branch information...
1 parent 3fd3a39 commit 07cd39b3779ed7003b9a6ab7625f571192f2f99e @weppos committed
View
7 lib/whois.rb
@@ -5,7 +5,7 @@
#
#
# Category:: Net
-# Package:: WWW::Delicious
+# Package:: Whois
# Author:: Simone Carletti <weppos@weppos.net>
# License:: MIT License
#
@@ -18,6 +18,7 @@
require 'whois/errors'
require 'whois/client'
require 'whois/server'
+require 'whois/definitions/tlds.rb'
module Whois
@@ -29,7 +30,7 @@ module Whois
end
module Kernel
- def whois(string)
- Whois::Client.new.query(string)
+ def whois(qstring)
+ Whois::Client.new.query(qstring)
end
end
View
18 lib/whois/client.rb
@@ -5,7 +5,7 @@
#
#
# Category:: Net
-# Package:: WWW::Delicious
+# Package:: Whois
# Author:: Simone Carletti <weppos@weppos.net>
# License:: MIT License
#
@@ -34,20 +34,10 @@ class Query
end
- def query(string)
- server = Server.whichwhois(string)
- ask_the_socket(string, server)
+ def query(qstring)
+ server = Server.guess(qstring)
+ server.query(qstring)
end
-
- private
-
- def ask_the_socket(query, server, port = 43)
- client = TCPSocket.open(server, port)
- client.write("#{query}\r\n") # I could use put(foo) and forget the \n
- client.read # but write/read sounds better than puts/read
- ensure # and I really want to use read instead of gets.
- client.close if client # If != client something went wrong.
- end
end
View
356 lib/whois/definitions/tlds.rb
@@ -0,0 +1,356 @@
+# WARNING: This file is autogenerated. Don't edit manually.
+
+Whois::Server.define ".br.com", "whois.centralnic.net"
+Whois::Server.define ".cn.com", "whois.centralnic.net"
+Whois::Server.define ".de.com", "whois.centralnic.net"
+Whois::Server.define ".eu.com", "whois.centralnic.net"
+Whois::Server.define ".gb.com", "whois.centralnic.net"
+Whois::Server.define ".gb.net", "whois.centralnic.net"
+Whois::Server.define ".hu.com", "whois.centralnic.net"
+Whois::Server.define ".no.com", "whois.centralnic.net"
+Whois::Server.define ".qc.com", "whois.centralnic.net"
+Whois::Server.define ".ru.com", "whois.centralnic.net"
+Whois::Server.define ".sa.com", "whois.centralnic.net"
+Whois::Server.define ".se.com", "whois.centralnic.net"
+Whois::Server.define ".se.net", "whois.centralnic.net"
+Whois::Server.define ".uk.com", "whois.centralnic.net"
+Whois::Server.define ".uk.net", "whois.centralnic.net"
+Whois::Server.define ".us.com", "whois.centralnic.net"
+Whois::Server.define ".uy.com", "whois.centralnic.net"
+Whois::Server.define ".za.com", "whois.centralnic.net"
+Whois::Server.define ".jpn.com", "whois.centralnic.net"
+Whois::Server.define ".web.com", "whois.centralnic.net"
+Whois::Server.define ".com", "whois.crsnic.net", {:adapter=>Whois::Server::Adapters::Verisign}
+Whois::Server.define ".za.net", "whois.za.net"
+Whois::Server.define ".net", "whois.crsnic.net", {:adapter=>Whois::Server::Adapters::Verisign}
+Whois::Server.define ".eu.org", "whois.eu.org"
+Whois::Server.define ".za.org", "whois.za.org"
+Whois::Server.define ".org", "whois.publicinterestregistry.net"
+Whois::Server.define ".edu", "whois.educause.net"
+Whois::Server.define ".gov", "whois.nic.gov"
+Whois::Server.define ".int", "whois.iana.org"
+Whois::Server.define ".mil", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".e164.arpa", "whois.ripe.net"
+Whois::Server.define ".in-addr.arpa", nil
+Whois::Server.define ".arpa", "whois.iana.org"
+Whois::Server.define ".aero", "whois.aero"
+Whois::Server.define ".asia", "whois.nic.asia"
+Whois::Server.define ".biz", "whois.nic.biz"
+Whois::Server.define ".cat", "whois.cat"
+Whois::Server.define ".coop", "whois.nic.coop"
+Whois::Server.define ".info", "whois.afilias.info"
+Whois::Server.define ".jobs", "jobswhois.verisign-grs.com"
+Whois::Server.define ".mobi", "whois.dotmobiregistry.net"
+Whois::Server.define ".museum", "whois.museum"
+Whois::Server.define ".name", "whois.nic.name"
+Whois::Server.define ".pro", "whois.registrypro.pro"
+Whois::Server.define ".tel", "whois.nic.tel"
+Whois::Server.define ".travel", "whois.nic.travel"
+Whois::Server.define ".ac", "whois.nic.ac"
+Whois::Server.define ".ad", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".ae", "whois.uaenic.ae"
+Whois::Server.define ".af", "whois.nic.af"
+Whois::Server.define ".ag", "whois.nic.ag"
+Whois::Server.define ".ai", "whois.ai"
+Whois::Server.define ".al", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".am", "whois.nic.am"
+Whois::Server.define ".an", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".ao", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".aq", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".ar", nil, {:web=>"http://www.nic.ar/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".as", "whois.nic.as"
+Whois::Server.define ".at", "whois.nic.at"
+Whois::Server.define ".au", "whois.ausregistry.net.au"
+Whois::Server.define ".aw", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".ax", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".az", nil, {:web=>"http://www.nic.az/AzCheck.htm", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".ba", nil, {:web=>"http://www.nic.ba/stream/whois/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".bb", nil, {:web=>"http://www.barbadosdomains.net/search_domain.php", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".bd", "www.whois.com.bd"
+Whois::Server.define ".be", "whois.dns.be"
+Whois::Server.define ".bf", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".bg", "whois.register.bg"
+Whois::Server.define ".bh", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".bi", nil, {:web=>"http://www.nic.bi/Nic_search.asp", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".bj", "whois.nic.bj"
+Whois::Server.define ".bm", nil, {:web=>"http://207.228.133.14/cgi-bin/lansaweb?procfun+BMWHO+BMWHO2+WHO", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".bn", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".bo", nil, {:web=>"http://www.nic.bo/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".br", "whois.nic.br"
+Whois::Server.define ".bs", nil, {:web=>"http://www.nic.bs/cgi-bin/search.pl", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".bt", nil, {:web=>"http://www.nic.bt/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".bv", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".by", nil, {:web=>"http://www.tld.by/indexeng.html", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".bw", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".bz", "whois.afilias-grs.info"
+Whois::Server.define ".co.ca", "whois.co.ca"
+Whois::Server.define ".ca", "whois.cira.ca"
+Whois::Server.define ".cc", "whois.nic.cc", {:adapter=>Whois::Server::Adapters::Verisign}
+Whois::Server.define ".cd", "whois.nic.cd"
+Whois::Server.define ".cf", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".cg", nil, {:web=>"http://www.nic.cg/cgi-bin/whois.pl", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".ch", "whois.nic.ch"
+Whois::Server.define ".ci", "www.nic.ci"
+Whois::Server.define ".ck", "whois.nic.ck"
+Whois::Server.define ".cl", "whois.nic.cl"
+Whois::Server.define ".cm", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".edu.cn", "whois.edu.cn"
+Whois::Server.define ".cn", "whois.cnnic.net.cn"
+Whois::Server.define ".uk.co", "whois.uk.co"
+Whois::Server.define ".co", nil, {:web=>"https://www.nic.co/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".cr", nil, {:web=>"http://www.nic.cr/niccr_publico/showRegistroDominiosScreen.do", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".cu", nil, {:web=>"http://www.nic.cu/consult.html", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".cv", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".cx", "whois.nic.cx"
+Whois::Server.define ".cy", nil, {:web=>"http://www.nic.cy/nslookup/online_database.php", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".cz", "whois.nic.cz"
+Whois::Server.define ".de", "whois.denic.de"
+Whois::Server.define ".dj", "whois.domain.dj"
+Whois::Server.define ".dk", "whois.dk-hostmaster.dk"
+Whois::Server.define ".dm", "whois.nic.dm"
+Whois::Server.define ".do", nil, {:web=>"http://www.nic.do/whois-h.php3", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".dz", nil, {:web=>"https://www.nic.dz/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".ec", nil, {:web=>"http://www.nic.ec/whois/eng/whois.asp", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".ee", "whois.eenet.ee"
+Whois::Server.define ".eg", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".er", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".es", nil, {:web=>"https://www.nic.es/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".et", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".eu", "whois.eu"
+Whois::Server.define ".fi", "whois.ficora.fi"
+Whois::Server.define ".fj", "whois.usp.ac.fj"
+Whois::Server.define ".fk", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".fm", nil, {:web=>"http://www.dot.fm/whois.html", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".fo", "whois.ripe.net"
+Whois::Server.define ".fr", "whois.nic.fr"
+Whois::Server.define ".ga", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".gb", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".gd", "whois.adamsnames.tc"
+Whois::Server.define ".ge", nil, {:web=>"http://whois.sanet.ge/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".gf", "whois.nplus.gf"
+Whois::Server.define ".gg", "whois.gg"
+Whois::Server.define ".gh", nil, {:web=>"http://www.nic.gh/customer/search_c.htm", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".gi", "whois.afilias-grs.info"
+Whois::Server.define ".gl", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".gm", "whois.ripe.net"
+Whois::Server.define ".gn", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".gp", "whois.nic.gp"
+Whois::Server.define ".gq", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".gr", nil, {:web=>"https://grweb.ics.forth.gr/Whois?lang=en", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".gs", "whois.nic.gs"
+Whois::Server.define ".gt", nil, {:web=>"http://www.gt/whois.htm", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".gu", nil, {:web=>"http://gadao.gov.gu/domainsearch.htm", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".gw", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".gy", "whois.registry.gy"
+Whois::Server.define ".hk", "whois.hkdnr.net.hk"
+Whois::Server.define ".hm", "whois.registry.hm"
+Whois::Server.define ".hn", "whois.afilias-grs.info"
+Whois::Server.define ".hr", nil, {:web=>"http://www.dns.hr/pretrazivanje.html", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".ht", "whois.nic.ht"
+Whois::Server.define ".hu", "whois.nic.hu"
+Whois::Server.define ".id", "whois.idnic.net.id"
+Whois::Server.define ".ie", "whois.domainregistry.ie"
+Whois::Server.define ".il", "whois.isoc.org.il"
+Whois::Server.define ".im", "whois.nic.im"
+Whois::Server.define ".in", "whois.registry.in"
+Whois::Server.define ".io", "whois.nic.io"
+Whois::Server.define ".iq", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".ir", "whois.nic.ir"
+Whois::Server.define ".is", "whois.isnet.is"
+Whois::Server.define ".it", "whois.nic.it"
+Whois::Server.define ".je", "whois.je"
+Whois::Server.define ".jm", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".jo", nil, {:web=>"http://www.dns.jo/Whois.aspx", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".jp", "whois.jprs.jp"
+Whois::Server.define ".ke", "whois.kenic.or.ke"
+Whois::Server.define ".kg", "whois.domain.kg"
+Whois::Server.define ".kh", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".ki", nil, {:web=>"http://www.ki/dns/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".km", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".kn", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".kp", "whois.kcce.kp"
+Whois::Server.define ".kr", "whois.nic.or.kr"
+Whois::Server.define ".kw", nil, {:web=>"http://www.kw/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".ky", nil, {:web=>"http://kynseweb.messagesecure.com/kywebadmin/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".kz", "whois.nic.kz"
+Whois::Server.define ".la", "whois.nic.la"
+Whois::Server.define ".lb", nil, {:web=>"http://www.aub.edu.lb/lbdr/search.html", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".lc", "whois.afilias-grs.info"
+Whois::Server.define ".li", "whois.nic.li"
+Whois::Server.define ".lk", "whois.nic.lk"
+Whois::Server.define ".lr", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".ls", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".lt", "whois.domreg.lt"
+Whois::Server.define ".lu", "whois.dns.lu"
+Whois::Server.define ".lv", "whois.nic.lv"
+Whois::Server.define ".ly", "whois.nic.ly"
+Whois::Server.define ".ma", "whois.iam.net.ma"
+Whois::Server.define ".mc", "whois.ripe.net"
+Whois::Server.define ".md", nil, {:web=>"http://www.dns.md/wh1.php", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".me", "whois.meregistry.net"
+Whois::Server.define ".mg", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".mh", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".mk", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".ml", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".mm", "whois.nic.mm"
+Whois::Server.define ".mn", "whois.afilias-grs.info"
+Whois::Server.define ".mo", nil, {:web=>"http://www.monic.net.mo/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".mp", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".mq", "whois.nic.mq"
+Whois::Server.define ".mr", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".ms", "whois.adamsnames.tc"
+Whois::Server.define ".mt", nil, {:web=>"https://www.nic.org.mt/dotmt/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".mu", "whois.nic.mu"
+Whois::Server.define ".mv", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".mw", nil, {:web=>"http://www.registrar.mw/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".mx", "whois.nic.mx"
+Whois::Server.define ".my", "whois.mynic.net.my"
+Whois::Server.define ".mz", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".na", "whois.na-nic.com.na"
+Whois::Server.define ".nc", "whois.cctld.nc"
+Whois::Server.define ".ne", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".nf", "whois.nic.nf"
+Whois::Server.define ".ng", "whois.register.net.ng"
+Whois::Server.define ".ni", nil, {:web=>"http://www.nic.ni/consulta.htm", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".nl", "whois.domain-registry.nl"
+Whois::Server.define ".no", "whois.norid.no"
+Whois::Server.define ".np", nil, {:web=>"http://www.mos.com.np/domsearch.html", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".nr", nil, {:web=>"http://www.cenpac.net.nr/dns/whois.html", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".nu", "whois.nic.nu"
+Whois::Server.define ".nz", "whois.srs.net.nz"
+Whois::Server.define ".om", nil, {:web=>"http://www.omnic.om/onlineUser/WHOISLookup.jsp", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".pa", nil, {:web=>"http://www.nic.pa/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".pe", "whois.nic.pe"
+Whois::Server.define ".pf", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".pg", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".ph", nil, {:web=>"http://whois.domains.ph/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".pk", nil, {:web=>"http://www.pknic.net.pk/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".co.pl", "whois.co.pl"
+Whois::Server.define ".pl", "whois.dns.pl"
+Whois::Server.define ".pm", "whois.nic.fr"
+Whois::Server.define ".pn", nil, {:web=>"http://www.pitcairn.pn/PnRegistry/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".pr", "whois.nic.pr"
+Whois::Server.define ".ps", nil, {:web=>"http://www.nic.ps/whois/whois.html", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".pt", "whois.dns.pt"
+Whois::Server.define ".pw", "whois.nic.pw"
+Whois::Server.define ".py", nil, {:web=>"http://www.nic.py/consultas.html", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".qa", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".re", "whois.nic.fr"
+Whois::Server.define ".ro", "whois.rotld.ro"
+Whois::Server.define ".rs", nil, {:web=>"http://www.nic.rs/en/whois", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".edu.ru", "whois.informika.ru"
+Whois::Server.define ".ru", "whois.ripn.net"
+Whois::Server.define ".rw", nil, {:web=>"http://www.nic.rw/cgi-bin/whoisrw.pl", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".sa", "saudinic.net.sa"
+Whois::Server.define ".sb", "whois.nic.net.sb"
+Whois::Server.define ".sc", "whois.afilias-grs.info"
+Whois::Server.define ".sd", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".se", "whois.nic-se.se"
+Whois::Server.define ".sg", "whois.nic.net.sg"
+Whois::Server.define ".sh", "whois.nic.sh"
+Whois::Server.define ".si", "whois.arnes.si"
+Whois::Server.define ".sj", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".sk", "whois.sk-nic.sk"
+Whois::Server.define ".sl", "whois.nic.sl"
+Whois::Server.define ".sm", "whois.ripe.net"
+Whois::Server.define ".sn", "whois.nic.sn"
+Whois::Server.define ".so", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".sr", "whois.register.sr"
+Whois::Server.define ".st", "whois.nic.st"
+Whois::Server.define ".su", "whois.ripn.net"
+Whois::Server.define ".sv", nil, {:web=>"http://www.uca.edu.sv/dns/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".sy", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".sz", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".tc", "whois.adamsnames.tc"
+Whois::Server.define ".td", nil, {:web=>"http://www.nic.td/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".tf", "whois.nic.tf"
+Whois::Server.define ".tg", nil, {:web=>"http://www.nic.tg/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".th", "whois.thnic.net"
+Whois::Server.define ".tj", "whois.nic.tj"
+Whois::Server.define ".tk", "whois.dot.tk"
+Whois::Server.define ".tl", "whois.nic.tl"
+Whois::Server.define ".tm", "whois.nic.tm"
+Whois::Server.define ".tn", nil, {:web=>"http://whois.ati.tn/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".to", "whois.tonic.to"
+Whois::Server.define ".tp", "whois.nic.tp"
+Whois::Server.define ".tr", "whois.metu.edu.tr"
+Whois::Server.define ".tt", nil, {:web=>"http://www.nic.tt/cgi-bin/search.pl", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".tv", "whois.nic.tv"
+Whois::Server.define ".tw", "whois.twnic.net"
+Whois::Server.define ".tz", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".ua", "whois.net.ua"
+Whois::Server.define ".ug", "www.registry.co.ug"
+Whois::Server.define ".ac.uk", "whois.ja.net"
+Whois::Server.define ".bl.uk", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".british-library.uk", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".gov.uk", "whois.ja.net"
+Whois::Server.define ".icnet.uk", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".jet.uk", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".mod.uk", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".nhs.uk", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".nls.uk", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".parliament.uk", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".police.uk", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".uk", "whois.nic.uk"
+Whois::Server.define ".fed.us", "whois.nic.gov"
+Whois::Server.define ".us", "whois.nic.us"
+Whois::Server.define ".com.uy", nil, {:web=>"https://nic.anteldata.com.uy/dns/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".uy", "www.rau.edu.uy"
+Whois::Server.define ".uz", "whois.cctld.uz"
+Whois::Server.define ".va", "whois.ripe.net"
+Whois::Server.define ".vc", "whois.afilias-grs.info"
+Whois::Server.define ".ve", "whois.nic.ve"
+Whois::Server.define ".vg", "whois.adamsnames.tc"
+Whois::Server.define ".vi", nil, {:web=>"http://www.nic.vi/whoisform.htm", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".vn", nil, {:web=>"http://www.vnnic.vn/english/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".vu", nil, {:web=>"http://www.vunic.vu/whois.html", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".wf", "whois.nic.wf"
+Whois::Server.define ".ws", "whois.samoanic.ws"
+Whois::Server.define ".ye", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".yt", "whois.nic.yt"
+Whois::Server.define ".yu", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".ac.za", "whois.ac.za"
+Whois::Server.define ".co.za", "whois.coza.net.za"
+Whois::Server.define ".gov.za", "whois.gov.za"
+Whois::Server.define ".org.za", nil, {:web=>"http://www.org.za/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define ".za", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".zm", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define ".zw", nil, {:adapter=>Whois::Server::Adapters::None}
+Whois::Server.define "-dom", "whois.networksolutions.com"
+Whois::Server.define "-org", "whois.networksolutions.com"
+Whois::Server.define "-hst", "whois.networksolutions.com"
+Whois::Server.define "-arin", "whois.arin.net"
+Whois::Server.define "-ripe", "whois.ripe.net"
+Whois::Server.define "-mnt", "whois.ripe.net"
+Whois::Server.define "-lacnic", "whois.lacnic.net"
+Whois::Server.define "-afrinic", "whois.afrinic.net"
+Whois::Server.define "-ap", "whois.apnic.net"
+Whois::Server.define "-ar", "whois.aunic.net"
+Whois::Server.define "-cn", "whois.cnnic.net.cn"
+Whois::Server.define "-cz", "whois.nic.cz"
+Whois::Server.define "-dk", "whois.dk-hostmaster.dk"
+Whois::Server.define "-il", "whois.isoc.org.il"
+Whois::Server.define "-is", "whois.isnet.is"
+Whois::Server.define "-kg", "whois.domain.kg"
+Whois::Server.define "-ti", "whois.telstra.net"
+Whois::Server.define "-tw", "whois.twnic.net"
+Whois::Server.define "-6bone", "whois.6bone.net"
+Whois::Server.define "-coop", "whois.nic.coop"
+Whois::Server.define "-cknic", "whois.nic.ck"
+Whois::Server.define "-idnic", "whois.idnic.net.id"
+Whois::Server.define "-itnic", "whois.nic.it"
+Whois::Server.define "-frnic", "whois.nic.fr"
+Whois::Server.define "-gandi", "whois.gandi.net"
+Whois::Server.define "-kenic", "whois.kenic.or.ke"
+Whois::Server.define "-lrms", "whois.afilias.info"
+Whois::Server.define "-metu", "whois.metu.edu.tr"
+Whois::Server.define "-nicat", "whois.nic.at"
+Whois::Server.define "-nicir", "whois.nic.ir"
+Whois::Server.define "-norid", "whois.norid.no"
+Whois::Server.define "-ripn", "whois.ripn.net"
+Whois::Server.define "-rotld", "whois.rotld.ro"
+Whois::Server.define "-sgnic", "whois.nic.net.sg"
+Whois::Server.define "-tel", "whois.nic.tel"
+Whois::Server.define "-uanic", "whois.com.ua"
+Whois::Server.define "-uynic", "www.rau.edu.uy"
+Whois::Server.define "-sixxs", "whois.sixxs.net"
View
154 lib/whois/server.rb
@@ -5,7 +5,7 @@
#
#
# Category:: Net
-# Package:: WWW::Delicious
+# Package:: Whois
# Author:: Simone Carletti <weppos@weppos.net>
# License:: MIT License
#
@@ -14,21 +14,42 @@
#++
-require 'yaml'
+require 'whois/server/adapters/base'
+require 'whois/server/adapters/standard'
+require 'whois/server/adapters/afilias'
+require 'whois/server/adapters/arpa'
+require 'whois/server/adapters/none'
+require 'whois/server/adapters/verisign'
+require 'whois/server/adapters/web'
module Whois
class Server
+ @@definitions = []
+
+ def self.define(extension, server, options = {})
+ @@definitions << [extension, server, options]
+ end
+
+ def self.definitions
+ @@definitions
+ end
+
+ def self.factory(definition)
+ extension, server, options = definition
+ (options.delete(:adapter) || Adapters::Standard).new(extension, server, options)
+ end
+
+
# Parses an user-supplied string and tries to guess the right server.
- def self.whichwhois(string)
+ def self.guess(qstring)
# TODO: IPv6 address
- # TODO: RPSL hierarchical objects
# Email Address
- if string =~ /@/
- find_for_email(string)
+ if qstring =~ /@/
+ find_for_email(qstring)
end
# TODO: NSI NIC
@@ -36,133 +57,28 @@ def self.whichwhois(string)
# TODO: IP
# Domain
- find_for_domain(string)
+ find_for_domain(qstring)
# TODO: guessing
# TODO: game-over
end
- def self.find_for_email(string)
+ def self.find_for_email(qstring)
raise ServerNotSupported, "No whois server is known for email objects"
end
- def self.find_for_domain(string)
- server = servers.each do |ext, srv|
- break(srv) if /#{ext}$/ =~ string
- end
-
- if server.nil?
- # you might want to remove this raise statement
- # to make the guessing more clever.
- raise ServerNotFound, "Unable to find a whois server for `#{string}'"
- elsif server =~ /^WEB (.*)/
- raise WebInterfaceError, "This TLD has no whois server, " +
- "but you can access the whois database at `#{$1}'"
- elsif server == "NONE"
- raise NoInterfaceError, "This TLD has no whois server"
- elsif server == "CRSNIC"
- query_crsnic(string)
- elsif server == "PIR"
- query_pir(string)
- elsif server == "AFILIAS"
- query_afilias(string)
- elsif server == "NICCC"
- query_niccc(string)
- elsif server == "ARPA"
- whichwhois(inaddr_to_ip(string))
- else
- server
+ def self.find_for_domain(qstring)
+ server = definitions.each do |definition|
+ return factory(definition) if /#{definition.first}$/ =~ qstring
end
- end
-
- def self.servers
- @@servers ||= YAML.load_file(File.dirname(__FILE__) + "/servers.yml")
+ # you might want to remove this raise statement
+ # to make the guessing more clever.
+ raise ServerNotFound, "Unable to find a whois server for `#{qstring}'"
end
private
- def self.ask_the_socket(query, server, port = 43)
- client = TCPSocket.open(server, port)
- client.write("#{query}\r\n")
- client.read
- ensure
- client.close if client
- end
-
-
- # FIXME: incomplete query handler
- # 1. if not found, the query returns the response
- # 2. if found, the query could return the response
- # 3. if found, the query could return a referral
- def self.query_crsnic(query)
- response = ask_the_socket("=#{query}", "whois.crsnic.net")
- if response =~ /Domain Name:/ && response =~ /Whois Server: (\S+)/
- return $1
- else
- # FIXME: Here's the full response. ARGH!
- end
- end
-
- # FIXME: incomplete query handler
- # It behavies like query_crsnic because the whois belongs to verisign.
- def self.query_niccc(query)
- response = ask_the_socket("=#{query}", "whois.nic.cc")
- if response =~ /Domain Name:/ && response =~ /Whois Server: (\S+)/
- return $1
- else
- # FIXME: Here's the full response. ARGH!
- end
- end
-
- # FIXME: incomplete query handler
- # 1. if not found, the query returns the response
- # 2. if found, the query could return the response (95% probs)
- # 3. if found, the query could return a referral
- def self.query_pir(query)
- response = ask_the_socket("FULL #{query}", "whois.publicinterestregistry.net")
- if response =~ /Registrant Name:SEE SPONSORING REGISTRAR/ &&
- response =~ /Registrant Street1:Whois Server:(\S+)/
- return $1
- else
- # FIXME: Here's the full response. ARGH!
- # Usually this happens for the 95% of queries. Isn't that wonderful?
- end
- end
-
- # FIXME: incomplete query handler
- # 1. if not found, the query returns the response
- # 2. if found, the query could return the response
- # 3. if found, the query could return a referral
- def self.query_afilias(query)
- response = ask_the_socket(query, "whois.afilias-grs.info")
- # TEST: ensure regexp matches
- if response =~ /Domain Name:/ && response =~ /Whois Server:(\S+)/
- return $1
- else
- # FIXME: Here's the full response. ARGH!
- end
- end
-
- # "127.1.168.192.in-addr.arpa" => "192.168.1.127"
- # "1.168.192.in-addr.arpa" => "192.168.1.0"
- # "168.192.in-addr.arpa" => "192.168.0.0"
- # "192.in-addr.arpa" => "192.0.0.0"
- # "in-addr.arpa" => "0.0.0.0"
- def self.inaddr_to_ip(query)
- unless /^([0-9]{1,3}\.?){0,4}in-addr\.arpa$/ =~ query
- raise ServerError, "Invalid .in-addr.arpa address"
- end
- a, b, c, d = query.scan(/[0-9]{1,3}\./).reverse
- [a, b, c, d].map do |token|
- token = (token ||= 0).to_i
- if token <= 255 && token >= 0
- token
- else
- raise ServerError, "Invalid .in-addr.arpa token `#{token}'"
- end
- end.join(".")
- end
end
View
36 lib/whois/server/adapters/afilias.rb
@@ -0,0 +1,36 @@
+#
+# = Ruby Whois
+#
+# A pure Ruby WHOIS client.
+#
+#
+# Category:: Net
+# Package:: Whois
+# Author:: Simone Carletti <weppos@weppos.net>
+# License:: MIT License
+#
+#--
+#
+#++
+
+
+module Whois
+ class Server
+ module Adapters
+
+ class Afilias < Base
+
+ def query(qstring)
+ response = ask_the_socket(qstring, "whois.afilias-grs.info")
+ if response =~ /Domain Name:/ && response =~ /Whois Server:(\S+)/
+ ask_the_socket(qstring, $1)
+ else
+ response
+ end
+ end
+
+ end
+
+ end
+ end
+end
View
53 lib/whois/server/adapters/arpa.rb
@@ -0,0 +1,53 @@
+#
+# = Ruby Whois
+#
+# A pure Ruby WHOIS client.
+#
+#
+# Category:: Net
+# Package:: Whois
+# Author:: Simone Carletti <weppos@weppos.net>
+# License:: MIT License
+#
+#--
+#
+#++
+
+
+module Whois
+ class Server
+ module Adapters
+
+ class Pir < Base
+
+ def query(qstring)
+ Server.guess(inaddr_to_ip(qstring)).query(qstring)
+ end
+
+ protected
+
+ # "127.1.168.192.in-addr.arpa" => "192.168.1.127"
+ # "1.168.192.in-addr.arpa" => "192.168.1.0"
+ # "168.192.in-addr.arpa" => "192.168.0.0"
+ # "192.in-addr.arpa" => "192.0.0.0"
+ # "in-addr.arpa" => "0.0.0.0"
+ def inaddr_to_ip(string)
+ unless /^([0-9]{1,3}\.?){0,4}in-addr\.arpa$/ =~ string
+ raise ServerError, "Invalid .in-addr.arpa address"
+ end
+ a, b, c, d = string.scan(/[0-9]{1,3}\./).reverse
+ [a, b, c, d].map do |token|
+ token = (token ||= 0).to_i
+ if token <= 255 && token >= 0
+ token
+ else
+ raise ServerError, "Invalid .in-addr.arpa token `#{token}'"
+ end
+ end.join(".")
+ end
+
+ end
+
+ end
+ end
+end
View
52 lib/whois/server/adapters/base.rb
@@ -0,0 +1,52 @@
+#
+# = Ruby Whois
+#
+# A pure Ruby WHOIS client.
+#
+#
+# Category:: Net
+# Package:: Whois
+# Author:: Simone Carletti <weppos@weppos.net>
+# License:: MIT License
+#
+#--
+#
+#++
+
+
+module Whois
+ class Server
+ module Adapters
+
+ class Base
+
+ attr_reader :extension
+ attr_reader :server
+ attr_reader :options
+
+ def initialize(extension, server, options = {})
+ @extension = extension
+ @server = server
+ @options = options || {}
+ end
+
+ def query(qstring)
+ raise NotImplementedError
+ end
+
+
+ private
+
+ def ask_the_socket(qstring, server, port = 43)
+ client = TCPSocket.open(server, port)
+ client.write("#{qstring}\r\n") # I could use put(foo) and forget the \n
+ client.read # but write/read sounds better than puts/read
+ ensure # and I really want to use read instead of gets.
+ client.close if client # If != client something went wrong.
+ end
+
+ end
+
+ end
+ end
+end
View
31 lib/whois/server/adapters/none.rb
@@ -0,0 +1,31 @@
+#
+# = Ruby Whois
+#
+# A pure Ruby WHOIS client.
+#
+#
+# Category:: Net
+# Package:: Whois
+# Author:: Simone Carletti <weppos@weppos.net>
+# License:: MIT License
+#
+#--
+#
+#++
+
+
+module Whois
+ class Server
+ module Adapters
+
+ class None < Base
+
+ def query(qstring)
+ raise NoInterfaceError, "This TLD has no whois server"
+ end
+
+ end
+
+ end
+ end
+end
View
37 lib/whois/server/adapters/pir.rb
@@ -0,0 +1,37 @@
+#
+# = Ruby Whois
+#
+# A pure Ruby WHOIS client.
+#
+#
+# Category:: Net
+# Package:: Whois
+# Author:: Simone Carletti <weppos@weppos.net>
+# License:: MIT License
+#
+#--
+#
+#++
+
+
+module Whois
+ class Server
+ module Adapters
+
+ class Pir < Base
+
+ def query(qstring)
+ response = ask_the_socket("FULL #{qstring}", "whois.publicinterestregistry.net")
+ if response =~ /Registrant Name:SEE SPONSORING REGISTRAR/ &&
+ response =~ /Registrant Street1:Whois Server:(\S+)/
+ ask_the_socket(qstring, $1)
+ else
+ response
+ end
+ end
+
+ end
+
+ end
+ end
+end
View
31 lib/whois/server/adapters/standard.rb
@@ -0,0 +1,31 @@
+#
+# = Ruby Whois
+#
+# A pure Ruby WHOIS client.
+#
+#
+# Category:: Net
+# Package:: Whois
+# Author:: Simone Carletti <weppos@weppos.net>
+# License:: MIT License
+#
+#--
+#
+#++
+
+
+module Whois
+ class Server
+ module Adapters
+
+ class Standard < Base
+
+ def query(qstring)
+ ask_the_socket(qstring, server, options[:port] || 43)
+ end
+
+ end
+
+ end
+ end
+end
View
36 lib/whois/server/adapters/verisign.rb
@@ -0,0 +1,36 @@
+#
+# = Ruby Whois
+#
+# A pure Ruby WHOIS client.
+#
+#
+# Category:: Net
+# Package:: Whois
+# Author:: Simone Carletti <weppos@weppos.net>
+# License:: MIT License
+#
+#--
+#
+#++
+
+
+module Whois
+ class Server
+ module Adapters
+
+ class Verisign < Base
+
+ def query(qstring)
+ response = ask_the_socket("=#{qstring}", "whois.crsnic.net")
+ if response =~ /Domain Name:/ && response =~ /Whois Server: (\S+)/
+ ask_the_socket(qstring, $1)
+ else
+ response
+ end
+ end
+
+ end
+
+ end
+ end
+end
View
32 lib/whois/server/adapters/web.rb
@@ -0,0 +1,32 @@
+#
+# = Ruby Whois
+#
+# A pure Ruby WHOIS client.
+#
+#
+# Category:: Net
+# Package:: Whois
+# Author:: Simone Carletti <weppos@weppos.net>
+# License:: MIT License
+#
+#--
+#
+#++
+
+
+module Whois
+ class Server
+ module Adapters
+
+ class Web < Base
+
+ def query(qstring)
+ raise WebInterfaceError, "This TLD has no whois server, " +
+ "but you can access the whois database at `#{options[:web]}'"
+ end
+
+ end
+
+ end
+ end
+end
View
709 lib/whois/servers.yml
@@ -1,709 +0,0 @@
----
-- - .br.com
- - whois.centralnic.net
-- - .cn.com
- - whois.centralnic.net
-- - .de.com
- - whois.centralnic.net
-- - .eu.com
- - whois.centralnic.net
-- - .gb.com
- - whois.centralnic.net
-- - .gb.net
- - whois.centralnic.net
-- - .hu.com
- - whois.centralnic.net
-- - .no.com
- - whois.centralnic.net
-- - .qc.com
- - whois.centralnic.net
-- - .ru.com
- - whois.centralnic.net
-- - .sa.com
- - whois.centralnic.net
-- - .se.com
- - whois.centralnic.net
-- - .se.net
- - whois.centralnic.net
-- - .uk.com
- - whois.centralnic.net
-- - .uk.net
- - whois.centralnic.net
-- - .us.com
- - whois.centralnic.net
-- - .uy.com
- - whois.centralnic.net
-- - .za.com
- - whois.centralnic.net
-- - .jpn.com
- - whois.centralnic.net
-- - .web.com
- - whois.centralnic.net
-- - .com
- - CRSNIC
-- - .za.net
- - whois.za.net
-- - .net
- - CRSNIC
-- - .eu.org
- - whois.eu.org
-- - .za.org
- - whois.za.org
-- - .org
- - PIR
-- - .edu
- - whois.educause.net
-- - .gov
- - whois.nic.gov
-- - .int
- - whois.iana.org
-- - .mil
- - NONE
-- - .e164.arpa
- - whois.ripe.net
-- - .in-addr.arpa
- - ARPA
-- - .arpa
- - whois.iana.org
-- - .aero
- - whois.aero
-- - .asia
- - whois.nic.asia
-- - .biz
- - whois.nic.biz
-- - .cat
- - whois.cat
-- - .coop
- - whois.nic.coop
-- - .info
- - whois.afilias.info
-- - .jobs
- - jobswhois.verisign-grs.com
-- - .mobi
- - whois.dotmobiregistry.net
-- - .museum
- - whois.museum
-- - .name
- - whois.nic.name
-- - .pro
- - whois.registrypro.pro
-- - .tel
- - whois.nic.tel
-- - .travel
- - whois.nic.travel
-- - .ac
- - whois.nic.ac
-- - .ad
- - NONE
-- - .ae
- - whois.uaenic.ae
-- - .af
- - whois.nic.af
-- - .ag
- - whois.nic.ag
-- - .ai
- - whois.ai
-- - .al
- - NONE
-- - .am
- - whois.nic.am
-- - .an
- - NONE
-- - .ao
- - NONE
-- - .aq
- - NONE
-- - .ar
- - WEB http://www.nic.ar/
-- - .as
- - whois.nic.as
-- - .at
- - whois.nic.at
-- - .au
- - whois.ausregistry.net.au
-- - .aw
- - NONE
-- - .ax
- - NONE
-- - .az
- - WEB http://www.nic.az/AzCheck.htm
-- - .ba
- - WEB http://www.nic.ba/stream/whois/
-- - .bb
- - WEB http://www.barbadosdomains.net/search_domain.php
-- - .bd
- - www.whois.com.bd
-- - .be
- - whois.dns.be
-- - .bf
- - NONE
-- - .bg
- - whois.register.bg
-- - .bh
- - NONE
-- - .bi
- - WEB http://www.nic.bi/Nic_search.asp
-- - .bj
- - whois.nic.bj
-- - .bm
- - WEB http://207.228.133.14/cgi-bin/lansaweb?procfun+BMWHO+BMWHO2+WHO
-- - .bn
- - NONE
-- - .bo
- - WEB http://www.nic.bo/
-- - .br
- - whois.nic.br
-- - .bs
- - WEB http://www.nic.bs/cgi-bin/search.pl
-- - .bt
- - WEB http://www.nic.bt/
-- - .bv
- - NONE
-- - .by
- - WEB http://www.tld.by/indexeng.html
-- - .bw
- - NONE
-- - .bz
- - AFILIAS
-- - .co.ca
- - whois.co.ca
-- - .ca
- - whois.cira.ca
-- - .cc
- - NICCC
-- - .cd
- - whois.nic.cd
-- - .cf
- - NONE
-- - .cg
- - WEB http://www.nic.cg/cgi-bin/whois.pl
-- - .ch
- - whois.nic.ch
-- - .ci
- - www.nic.ci
-- - .ck
- - whois.nic.ck
-- - .cl
- - whois.nic.cl
-- - .cm
- - NONE
-- - .edu.cn
- - whois.edu.cn
-- - .cn
- - whois.cnnic.net.cn
-- - .uk.co
- - whois.uk.co
-- - .co
- - WEB https://www.nic.co/
-- - .cr
- - WEB http://www.nic.cr/niccr_publico/showRegistroDominiosScreen.do
-- - .cu
- - WEB http://www.nic.cu/consult.html
-- - .cv
- - NONE
-- - .cx
- - whois.nic.cx
-- - .cy
- - WEB http://www.nic.cy/nslookup/online_database.php
-- - .cz
- - whois.nic.cz
-- - .de
- - whois.denic.de
-- - .dj
- - whois.domain.dj
-- - .dk
- - whois.dk-hostmaster.dk
-- - .dm
- - whois.nic.dm
-- - .do
- - WEB http://www.nic.do/whois-h.php3
-- - .dz
- - WEB https://www.nic.dz/
-- - .ec
- - WEB http://www.nic.ec/whois/eng/whois.asp
-- - .ee
- - whois.eenet.ee
-- - .eg
- - NONE
-- - .er
- - NONE
-- - .es
- - WEB https://www.nic.es/
-- - .et
- - NONE
-- - .eu
- - whois.eu
-- - .fi
- - whois.ficora.fi
-- - .fj
- - whois.usp.ac.fj
-- - .fk
- - NONE
-- - .fm
- - WEB http://www.dot.fm/whois.html
-- - .fo
- - whois.ripe.net
-- - .fr
- - whois.nic.fr
-- - .ga
- - NONE
-- - .gb
- - NONE
-- - .gd
- - whois.adamsnames.tc
-- - .ge
- - WEB http://whois.sanet.ge/
-- - .gf
- - whois.nplus.gf
-- - .gg
- - whois.gg
-- - .gh
- - WEB http://www.nic.gh/customer/search_c.htm
-- - .gi
- - AFILIAS
-- - .gl
- - NONE
-- - .gm
- - whois.ripe.net
-- - .gn
- - NONE
-- - .gp
- - whois.nic.gp
-- - .gq
- - NONE
-- - .gr
- - WEB https://grweb.ics.forth.gr/Whois?lang=en
-- - .gs
- - whois.nic.gs
-- - .gt
- - WEB http://www.gt/whois.htm
-- - .gu
- - WEB http://gadao.gov.gu/domainsearch.htm
-- - .gw
- - NONE
-- - .gy
- - whois.registry.gy
-- - .hk
- - whois.hkdnr.net.hk
-- - .hm
- - whois.registry.hm
-- - .hn
- - AFILIAS
-- - .hr
- - WEB http://www.dns.hr/pretrazivanje.html
-- - .ht
- - whois.nic.ht
-- - .hu
- - whois.nic.hu
-- - .id
- - whois.idnic.net.id
-- - .ie
- - whois.domainregistry.ie
-- - .il
- - whois.isoc.org.il
-- - .im
- - whois.nic.im
-- - .in
- - whois.registry.in
-- - .io
- - whois.nic.io
-- - .iq
- - NONE
-- - .ir
- - whois.nic.ir
-- - .is
- - whois.isnet.is
-- - .it
- - whois.nic.it
-- - .je
- - whois.je
-- - .jm
- - NONE
-- - .jo
- - WEB http://www.dns.jo/Whois.aspx
-- - .jp
- - whois.jprs.jp
-- - .ke
- - whois.kenic.or.ke
-- - .kg
- - whois.domain.kg
-- - .kh
- - NONE
-- - .ki
- - WEB http://www.ki/dns/
-- - .km
- - NONE
-- - .kn
- - NONE
-- - .kp
- - whois.kcce.kp
-- - .kr
- - whois.nic.or.kr
-- - .kw
- - WEB http://www.kw/
-- - .ky
- - WEB http://kynseweb.messagesecure.com/kywebadmin/
-- - .kz
- - whois.nic.kz
-- - .la
- - whois.nic.la
-- - .lb
- - WEB http://www.aub.edu.lb/lbdr/search.html
-- - .lc
- - AFILIAS
-- - .li
- - whois.nic.li
-- - .lk
- - whois.nic.lk
-- - .lr
- - NONE
-- - .ls
- - NONE
-- - .lt
- - whois.domreg.lt
-- - .lu
- - whois.dns.lu
-- - .lv
- - whois.nic.lv
-- - .ly
- - whois.nic.ly
-- - .ma
- - whois.iam.net.ma
-- - .mc
- - whois.ripe.net
-- - .md
- - WEB http://www.dns.md/wh1.php
-- - .me
- - whois.meregistry.net
-- - .mg
- - NONE
-- - .mh
- - NONE
-- - .mk
- - NONE
-- - .ml
- - NONE
-- - .mm
- - whois.nic.mm
-- - .mn
- - AFILIAS
-- - .mo
- - WEB http://www.monic.net.mo/
-- - .mp
- - NONE
-- - .mq
- - whois.nic.mq
-- - .mr
- - NONE
-- - .ms
- - whois.adamsnames.tc
-- - .mt
- - WEB https://www.nic.org.mt/dotmt/
-- - .mu
- - whois.nic.mu
-- - .mv
- - NONE
-- - .mw
- - WEB http://www.registrar.mw/
-- - .mx
- - whois.nic.mx
-- - .my
- - whois.mynic.net.my
-- - .mz
- - NONE
-- - .na
- - whois.na-nic.com.na
-- - .nc
- - whois.cctld.nc
-- - .ne
- - NONE
-- - .nf
- - whois.nic.nf
-- - .ng
- - whois.register.net.ng
-- - .ni
- - WEB http://www.nic.ni/consulta.htm
-- - .nl
- - whois.domain-registry.nl
-- - .no
- - whois.norid.no
-- - .np
- - WEB http://www.mos.com.np/domsearch.html
-- - .nr
- - WEB http://www.cenpac.net.nr/dns/whois.html
-- - .nu
- - whois.nic.nu
-- - .nz
- - whois.srs.net.nz
-- - .om
- - WEB http://www.omnic.om/onlineUser/WHOISLookup.jsp
-- - .pa
- - WEB http://www.nic.pa/
-- - .pe
- - whois.nic.pe
-- - .pf
- - NONE
-- - .pg
- - NONE
-- - .ph
- - WEB http://whois.domains.ph/
-- - .pk
- - WEB http://www.pknic.net.pk/
-- - .co.pl
- - whois.co.pl
-- - .pl
- - whois.dns.pl
-- - .pm
- - whois.nic.fr
-- - .pn
- - WEB http://www.pitcairn.pn/PnRegistry/
-- - .pr
- - whois.nic.pr
-- - .ps
- - WEB http://www.nic.ps/whois/whois.html
-- - .pt
- - whois.dns.pt
-- - .pw
- - whois.nic.pw
-- - .py
- - WEB http://www.nic.py/consultas.html
-- - .qa
- - NONE
-- - .re
- - whois.nic.fr
-- - .ro
- - whois.rotld.ro
-- - .rs
- - WEB http://www.nic.rs/en/whois
-- - .edu.ru
- - whois.informika.ru
-- - .ru
- - whois.ripn.net
-- - .rw
- - WEB http://www.nic.rw/cgi-bin/whoisrw.pl
-- - .sa
- - saudinic.net.sa
-- - .sb
- - whois.nic.net.sb
-- - .sc
- - AFILIAS
-- - .sd
- - NONE
-- - .se
- - whois.nic-se.se
-- - .sg
- - whois.nic.net.sg
-- - .sh
- - whois.nic.sh
-- - .si
- - whois.arnes.si
-- - .sj
- - NONE
-- - .sk
- - whois.sk-nic.sk
-- - .sl
- - whois.nic.sl
-- - .sm
- - whois.ripe.net
-- - .sn
- - whois.nic.sn
-- - .so
- - NONE
-- - .sr
- - whois.register.sr
-- - .st
- - whois.nic.st
-- - .su
- - whois.ripn.net
-- - .sv
- - WEB http://www.uca.edu.sv/dns/
-- - .sy
- - NONE
-- - .sz
- - NONE
-- - .tc
- - whois.adamsnames.tc
-- - .td
- - WEB http://www.nic.td/
-- - .tf
- - whois.nic.tf
-- - .tg
- - WEB http://www.nic.tg/
-- - .th
- - whois.thnic.net
-- - .tj
- - whois.nic.tj
-- - .tk
- - whois.dot.tk
-- - .tl
- - whois.nic.tl
-- - .tm
- - whois.nic.tm
-- - .tn
- - WEB http://whois.ati.tn/
-- - .to
- - whois.tonic.to
-- - .tp
- - whois.nic.tp
-- - .tr
- - whois.metu.edu.tr
-- - .tt
- - WEB http://www.nic.tt/cgi-bin/search.pl
-- - .tv
- - whois.nic.tv
-- - .tw
- - whois.twnic.net
-- - .tz
- - NONE
-- - .ua
- - whois.net.ua
-- - .ug
- - www.registry.co.ug
-- - .ac.uk
- - whois.ja.net
-- - .bl.uk
- - NONE
-- - .british-library.uk
- - NONE
-- - .gov.uk
- - whois.ja.net
-- - .icnet.uk
- - NONE
-- - .jet.uk
- - NONE
-- - .mod.uk
- - NONE
-- - .nhs.uk
- - NONE
-- - .nls.uk
- - NONE
-- - .parliament.uk
- - NONE
-- - .police.uk
- - NONE
-- - .uk
- - whois.nic.uk
-- - .fed.us
- - whois.nic.gov
-- - .us
- - whois.nic.us
-- - .com.uy
- - WEB https://nic.anteldata.com.uy/dns/
-- - .uy
- - www.rau.edu.uy
-- - .uz
- - whois.cctld.uz
-- - .va
- - whois.ripe.net
-- - .vc
- - AFILIAS
-- - .ve
- - whois.nic.ve
-- - .vg
- - whois.adamsnames.tc
-- - .vi
- - WEB http://www.nic.vi/whoisform.htm
-- - .vn
- - WEB http://www.vnnic.vn/english/
-- - .vu
- - WEB http://www.vunic.vu/whois.html
-- - .wf
- - whois.nic.wf
-- - .ws
- - whois.samoanic.ws
-- - .ye
- - NONE
-- - .yt
- - whois.nic.yt
-- - .yu
- - NONE
-- - .ac.za
- - whois.ac.za
-- - .co.za
- - whois.coza.net.za
-- - .gov.za
- - whois.gov.za
-- - .org.za
- - WEB http://www.org.za/
-- - .za
- - NONE
-- - .zm
- - NONE
-- - .zw
- - NONE
-- - -dom
- - whois.networksolutions.com
-- - -org
- - whois.networksolutions.com
-- - -hst
- - whois.networksolutions.com
-- - -arin
- - whois.arin.net
-- - -ripe
- - whois.ripe.net
-- - -mnt
- - whois.ripe.net
-- - -lacnic
- - whois.lacnic.net
-- - -afrinic
- - whois.afrinic.net
-- - -ap
- - whois.apnic.net
-- - -ar
- - whois.aunic.net
-- - -cn
- - whois.cnnic.net.cn
-- - -cz
- - whois.nic.cz
-- - -dk
- - whois.dk-hostmaster.dk
-- - -il
- - whois.isoc.org.il
-- - -is
- - whois.isnet.is
-- - -kg
- - whois.domain.kg
-- - -ti
- - whois.telstra.net
-- - -tw
- - whois.twnic.net
-- - -6bone
- - whois.6bone.net
-- - -coop
- - whois.nic.coop
-- - -cknic
- - whois.nic.ck
-- - -idnic
- - whois.idnic.net.id
-- - -itnic
- - whois.nic.it
-- - -frnic
- - whois.nic.fr
-- - -gandi
- - whois.gandi.net
-- - -kenic
- - whois.kenic.or.ke
-- - -lrms
- - whois.afilias.info
-- - -metu
- - whois.metu.edu.tr
-- - -nicat
- - whois.nic.at
-- - -nicir
- - whois.nic.ir
-- - -norid
- - whois.norid.no
-- - -ripn
- - whois.ripn.net
-- - -rotld
- - whois.rotld.ro
-- - -sgnic
- - whois.nic.net.sg
-- - -tel
- - whois.nic.tel
-- - -uanic
- - whois.com.ua
-- - -uynic
- - www.rau.edu.uy
-- - -sixxs
- - whois.sixxs.net
View
2 lib/whois/version.rb
@@ -5,7 +5,7 @@
#
#
# Category:: Net
-# Package:: WWW::Delicious
+# Package:: Whois
# Author:: Simone Carletti <weppos@weppos.net>
# License:: MIT License
#
View
39 tasks/server.rake
@@ -1,18 +1,47 @@
namespace :server do
- desc "server:convert_file_tld"
- task :convert_file_tld do
+ desc "server:convert_file_tlds"
+ task :convert_file_tlds do
servers = File.readlines("data/tld_serv_list").map do |line|
line.chomp!
line.gsub!(/^\s*(.*)\s*$/, '\1')
line.gsub!(/\s*#.*$/, '')
if line =~ /^([\w\d\.-]+)\s+([\w\d\.:-]+|[A-Z]+\s+.*)$/
- extension, server = $1, $2
- [extension, server]
+ extension, instructions = $1, $2
+ server, options = case
+ when instructions == "NONE"
+ [nil, { :adapter => Whois::Server::Adapters::None }]
+ when instructions == "ARPA"
+ [nil, { :adapter => Whois::Server::Adapters::Arpa }]
+ when instructions =~ /^WEB (.*)$/
+ [nil, { :adapter => Whois::Server::Adapters::Web, :web => $1 }]
+ when instructions == "CRSNIC"
+ ["whois.crsnic.net", { :adapter => Whois::Server::Adapters::Verisign }]
+ when instructions == "PIR"
+ ["whois.publicinterestregistry.net", { :adapter => Whois::Server::Adapters::Pir }]
+ when instructions == "AFILIAS"
+ ["whois.afilias-grs.info", { :adapter => Whois::Server::Adapters::Afilias }]
+ when instructions == "NICCC"
+ ["whois.nic.cc", { :adapter => Whois::Server::Adapters::Verisign }]
+ else
+ [instructions]
+ end
+
+ <<-RUBY
+Whois::Server.define #{extension.inspect}, \
+#{server.inspect}\
+#{options.nil? ? "" : ", " + options.inspect}
+ RUBY
end
end.reject { |value| value == '' || value.nil? }
- File.open("lib/whois/servers.yml", "w+") { |f| f.write(YAML.dump(servers)) }
+ File.open("lib/whois/definitions/tlds.rb", "w+") do |f|
+ f.write(<<-HEADER)
+# WARNING: This file is autogenerated. Don't edit manually.
+
+ HEADER
+ f.write(servers)
+ end
puts "Created file with #{servers.size} servers."
end

0 comments on commit 07cd39b

Please sign in to comment.
Something went wrong with that request. Please try again.