]> projects.mako.cc - selectricity-live/blobdiff - lib/whois/whois.rb
Fix WHOIS library not to puke on strange IP addresses
[selectricity-live] / lib / whois / whois.rb
index 9b07aef9e5108a37d46b39e634fc29592a053d8d..88c735ba4f4309a0d3746646f4bc5ad731c69263 100755 (executable)
@@ -121,9 +121,10 @@ module Whois
           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::Ripe.new
           end
         end
 
@@ -132,7 +133,7 @@ module Whois
           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::Ripe.new
           else
             return server
           end
@@ -143,7 +144,7 @@ module Whois
           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

Benjamin Mako Hill || Want to submit a patch?