Created
February 13, 2009 14:28
-
-
Save mutle/63925 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'json' | |
require 'sinatra' | |
File.open('whois_proxy.pid', 'w') { |f| f.write(Process.pid) } | |
get '/whois/:tld/:domain' do | |
domain = (params['domain'] || '').gsub(/[^a-zA-Z0-9\-\_]/, '') | |
tld = (params['tld'] || '').gsub(/[^a-zA-Z0-9\-\_]/, '') | |
available = false | |
fqdn = "#{domain}.#{tld}" | |
if domain != '' and tld != '' | |
hostcheck = `host #{fqdn}` | |
if hostcheck.include?("does not exist") or hostcheck.include?("not found") | |
whois = `whois #{fqdn}` | |
available = true if whois.include?("No match") or whois.include?("not found in database") or whois.include?("NOT FOUND") | |
end | |
end | |
{ | |
"#{params['domain']}.#{params['tld']}" => available | |
}.to_json | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment