Skip to content

Commit

Permalink
Merge 5a75c09 into 0ec4a34
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed Jul 21, 2016
2 parents 0ec4a34 + 5a75c09 commit 08abc82
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 7 deletions.
20 changes: 14 additions & 6 deletions data/tld.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@
"host": "whois.nic.bo"
},
".br": {
"host": "whois.registro.br"
"host": "whois.registro.br",
"adapter": "nicbr"
},
".bs": {
"adapter": "web",
Expand Down Expand Up @@ -3001,20 +3002,27 @@
".xn--czru2d": {
"host": "whois.gtld.knet.cn"
},

// whois.gtlds.nic.br
".globo": {
"host": "whois.gtlds.nic.br"
"host": "whois.gtlds.nic.br",
"adapter": "nicbr"
},
".bom": {
"host": "whois.gtlds.nic.br"
"host": "whois.gtlds.nic.br",
"adapter": "nicbr"
},
".final": {
"host": "whois.gtlds.nic.br"
"host": "whois.gtlds.nic.br",
"adapter": "nicbr"
},
".rio": {
"host": "whois.gtlds.nic.br"
"host": "whois.gtlds.nic.br",
"adapter": "nicbr"
},
".uol": {
"host": "whois.gtlds.nic.br"
"host": "whois.gtlds.nic.br",
"adapter": "nicbr"
},

// whois.nic.*
Expand Down
1 change: 1 addition & 0 deletions lib/whois/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module Adapters
autoload :Arpa, "whois/server/adapters/arpa"
autoload :Afilias, "whois/server/adapters/afilias"
autoload :Formatted, "whois/server/adapters/formatted"
autoload :Nicbr, "whois/server/adapters/nicbr"
autoload :None, "whois/server/adapters/none"
autoload :NotImplemented, "whois/server/adapters/not_implemented"
autoload :Standard, "whois/server/adapters/standard"
Expand Down
51 changes: 51 additions & 0 deletions lib/whois/server/adapters/nicbr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2016 Simone Carletti <weppos@weppos.net>
#++


module Whois
class Server
module Adapters

#
# = NICbr Adapter
#
# Provides ability to query NICbr WHOIS interfaces.
#
class Nicbr < Base

# Executes a WHOIS query to the NICbr WHOIS interface,
# resolving any intermediate referral,
# and appends the response to the client buffer.
#
# @param [String] string
# @return [void]
#
def request(string)
response = query_the_socket(string, host)
buffer_append response, host

if options[:referral] != false && referral = extract_referral(response)
response = query_the_socket(string, referral)
buffer_append(response, referral)
end
end


private

def extract_referral(response)
if response =~ /Domain Name:/
response.slice(/Whois Server:(\S+)/, 1)
end
end

end

end
end
end
62 changes: 62 additions & 0 deletions spec/fixtures/referrals/nicbr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Domain Name: nic.rio
Domain ID: D54-RIO
WHOIS Server: whois.gtlds.nic.br
Referral URL: http://gtlds.nic.br
Updated Date: 2015-05-12T19:56:09Z
Creation Date: 2014-05-19T22:46:02Z
Registry Expiry Date: 2025-05-19T22:46:02Z
Sponsoring Registrar: NIC.br New gTLD Back-End Registry Services
Sponsoring Registrar IANA ID: 9999
Domain Status: ok https://www.icann.org/epp#ok
Registrant ID: C4R3-NICBR
Registrant Name: Empresa Municipal de Informatica SA - IPLANRIO
Registrant Organization: 73.214.439/0001-90
Registrant Street: Av. Presidente Vargas 3131 Sala 1204
Registrant City: Rio de Janeiro
Registrant State/Province: RJ
Registrant Postal Code: 20210-030
Registrant Country: BR
Registrant Phone: +55.2139711818
Registrant Fax:
Registrant Email: gtlds-rio@registro.br
Admin ID: C4R3-NICBR
Admin Name: Empresa Municipal de Informatica SA - IPLANRIO
Admin Organization: 73.214.439/0001-90
Admin Street: Av. Presidente Vargas 3131 Sala 1204
Admin City: Rio de Janeiro
Admin State/Province: RJ
Admin Postal Code: 20210-030
Admin Country: BR
Admin Phone: +55.2139711818
Admin Fax:
Admin Email: gtlds-rio@registro.br
Tech ID: C4R3-NICBR
Tech Name: Empresa Municipal de Informatica SA - IPLANRIO
Tech Organization: 73.214.439/0001-90
Tech Street: Av. Presidente Vargas 3131 Sala 1204
Tech City: Rio de Janeiro
Tech State/Province: RJ
Tech Postal Code: 20210-030
Tech Country: BR
Tech Phone: +55.2139711818
Tech Fax:
Tech Email: gtlds-rio@registro.br
Name Server: ns.dns.br
Name Server: ns2.dns.br
DNSSEC: signedDelegation

>>> Last update of WHOIS database: 2016-07-20T18:04:56Z <<<

For more information on Whois status codes, please visit https://icann.org/epp

% The queried data can only be used for technical or
% administrative requirements associated with the Internet
% or in order to contact the domain or block holder over
% legal problems, being prohibited the distribution,
% repackaging, modification, comercialization or
% reproduction, in particular, to use it for advertising or
% any similar purpose;
%
% Any prohibited use or harvesting, may cause, without
% previous warning, access restriction, without prejudice
% of future legal action.
25 changes: 25 additions & 0 deletions spec/whois/server/adapters/nicbr_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'spec_helper'

describe Whois::Server::Adapters::Nicbr do

let(:definition) { [:tld, ".test", "whois.gtlds.nic.br", {}] }
let(:server) { described_class.new(*definition) }


describe "#lookup" do
context "without referral" do
it "returns the WHOIS record" do
response = "No match for example.test."
expected = response
expect(server.query_handler).to receive(:call).with("example.test", "whois.gtlds.nic.br", 43).and_return(response)

record = server.lookup("example.test")
expect(record.to_s).to eq(expected)
expect(record.parts.size).to eq(1)
expect(record.parts).to eq([Whois::Record::Part.new(body: response, host: "whois.gtlds.nic.br")])
end
end

end

end
2 changes: 1 addition & 1 deletion whois.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.description = "Whois is an intelligent WHOIS client and parser written in pure Ruby. It can query registry data for IPv4, IPv6 and top level domains, parse and convert responses into easy-to-use Ruby objects."
s.email = ["weppos@weppos.net"]
s.executables = ["whoisrb"]
s.files = [".yardopts", "CHANGELOG.md", "CONTRIBUTING.md", "LICENSE.txt", "README.md", "bin/whoisrb", "data/asn16.json", "data/asn32.json", "data/ipv4.json", "data/ipv6.json", "data/tld.json", "lib/whois.rb", "lib/whois/client.rb", "lib/whois/errors.rb", "lib/whois/record.rb", "lib/whois/record/part.rb", "lib/whois/server.rb", "lib/whois/server/adapters/afilias.rb", "lib/whois/server/adapters/arin.rb", "lib/whois/server/adapters/arpa.rb", "lib/whois/server/adapters/base.rb", "lib/whois/server/adapters/formatted.rb", "lib/whois/server/adapters/none.rb", "lib/whois/server/adapters/not_implemented.rb", "lib/whois/server/adapters/standard.rb", "lib/whois/server/adapters/verisign.rb", "lib/whois/server/adapters/web.rb", "lib/whois/server/socket_handler.rb", "lib/whois/version.rb", "whois.gemspec"]
s.files = [".yardopts", "CHANGELOG.md", "CONTRIBUTING.md", "LICENSE.txt", "README.md", "bin/whoisrb", "data/asn16.json", "data/asn32.json", "data/ipv4.json", "data/ipv6.json", "data/tld.json", "lib/whois.rb", "lib/whois/client.rb", "lib/whois/errors.rb", "lib/whois/record.rb", "lib/whois/record/part.rb", "lib/whois/server.rb", "lib/whois/server/adapters/afilias.rb", "lib/whois/server/adapters/nicbr.rb", "lib/whois/server/adapters/arin.rb", "lib/whois/server/adapters/arpa.rb", "lib/whois/server/adapters/base.rb", "lib/whois/server/adapters/formatted.rb", "lib/whois/server/adapters/none.rb", "lib/whois/server/adapters/not_implemented.rb", "lib/whois/server/adapters/standard.rb", "lib/whois/server/adapters/verisign.rb", "lib/whois/server/adapters/web.rb", "lib/whois/server/socket_handler.rb", "lib/whois/version.rb", "whois.gemspec"]
s.homepage = "http://whoisrb.org/"
s.licenses = ["MIT"]
s.post_install_message = "********************************************************************************\n\n Thank you for installing the whois gem!\n\n If you like this gem, please support the project.\n http://pledgie.com/campaigns/11383\n\n Does your project or organization use this gem? Add it to the apps wiki.\n https://github.com/weppos/whois/wiki/apps\n\n********************************************************************************\n"
Expand Down

0 comments on commit 08abc82

Please sign in to comment.