Created
December 26, 2011 15:22
-
-
Save tarolandia/1521384 to your computer and use it in GitHub Desktop.
whois server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
require 'whois' | |
require 'json' | |
get '/whois/:domain' do |domain| | |
c = Whois::Client.new | |
r = c.query(domain) | |
puts r | |
r | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
require 'whois' | |
require 'json' | |
get '/whois/:domain' do |domain| | |
c = Whois::Client.new | |
r = c.query(domain) | |
t = r.registrar | |
if t.name.nil? | |
if r.to_s.downcase =~ /godaddy.com,\sinc/ | |
response = { :domain => domain, :registrar => "godaddy" } | |
else | |
response = {} | |
end | |
else | |
response = { :domain => domain, :registrar => t.name } | |
end | |
response.to_json | |
#r.to_s.downcase | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
require 'whois' | |
require 'json' | |
get '/whois/:domain' do |domain| | |
dom_parts = domain.split(".") | |
status = false | |
until dom_parts.size < 2 or status | |
begin | |
c = Whois::Client.new | |
r = c.query(dom_parts.join(".")) | |
status = true | |
rescue Whois::Error => e | |
dom_parts.shift | |
end | |
end | |
response = Hash.new | |
response[:registrar] = "" | |
if status | |
t = r.registrar | |
if t.name.nil? | |
if r.to_s.downcase =~ /godaddy.com,\sinc/ | |
response[:registrar] = "GoDaddy.com, Inc." | |
end | |
else | |
response[:registrar] = t.name | |
end | |
end | |
response.to_json | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment