require 'resolv'
require 'ipaddr'
require 'yaml'
+require 'timeout'
+
require File.dirname(__FILE__) + '/server/server'
# Module for manage all Whois Class
def search_host
begin
if @host_search
- @host = Resolv.getname self.ip.to_s
+ begin
+ timeout(5) {@host = Resolv.getname self.ip.to_s}
+ rescue Timeout::Error
+ @host=nil
+ end
else
@host = nil
end
arr_tmp = ip_hash.sort{|b,c| c[0][/\/(.+)/, 1].to_i <=> b[0][/\/(.+)/, 1].to_i}
arr_tmp.each do |l|
ip_range = IPAddr.new l[0]
- if ip_range.include? self.ip
+ if ip_range.include? self.ip and l[1].length > 0
return Object.instance_eval("Server::#{l[1]}.new")
end
+ return Server::Arin.new
end
end
ipv6_list = YAML::load_file(File.dirname(__FILE__) + '/data/ipv6.yaml')
server = server_with_hash(ipv6_list)
unless server.kind_of? Server::Server
- raise WhoisException.new("no server found for this IPv6 : #{self.ip}")
+ return Server::Arin.new
else
return server
end
ipv4_list = YAML::load_file(File.dirname(__FILE__) + '/data/ipv4.yaml')
server = server_with_hash(ipv4_list)
unless server.kind_of? Server::Server
- raise WhoisException.new("no server found for this IPv4 : #{self.ip}")
+ return Server::Ripe.new
else
return server
end