Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Whois::Server may occasionally raise an error trying to resolve an IP…

…v6 matching query object (GH-174).

Thanks @aeden
  • Loading branch information...
commit 0e0339ab1c7d96f17d7d0007475d753e811949ad 1 parent e44d69c
@weppos authored
Showing with 22 additions and 7 deletions.
  1. +2 −0  CHANGELOG.md
  2. +9 −5 lib/whois/server.rb
  3. +11 −2 spec/whois/server_spec.rb
View
2  CHANGELOG.md
@@ -8,6 +8,8 @@
* FIXED: whois.ua parser raises ArgumentError when the created_on object invalid data.
+* FIXED: Whois::Server may occasionally raise an error trying to resolve an IPv6 matching query object (GH-174). [Thanks @aeden].
+
* CHANGED: Updated whois.registrypro.pro parser to the new response format.
View
14 lib/whois/server.rb
@@ -239,12 +239,16 @@ def self.matches_email?(string)
def self.find_for_ip(string)
- ip = IPAddr.new(string)
- type = ip.ipv4? ? :ipv4 : :ipv6
- definitions(type).each do |definition|
- if IPAddr.new(definition.first).include?(ip)
- return factory(type, *definition)
+ begin
+ ip = IPAddr.new(string)
+ type = ip.ipv4? ? :ipv4 : :ipv6
+ definitions(type).each do |definition|
+ if IPAddr.new(definition.first).include?(ip)
+ return factory(type, *definition)
+ end
end
+ rescue ArgumentError => error
+ # continue
end
raise AllocationUnknown, "IP Allocation for `#{string}' unknown. Server definitions might be outdated."
end
View
13 spec/whois/server_spec.rb
@@ -182,9 +182,9 @@
it "raises if definition is not found" do
with_definitions do
Whois::Server.define(:ipv6, "::1", "whois.test")
- lambda do
+ lambda {
Whois::Server.guess("2002:0300::1")
- end.should raise_error(Whois::AllocationUnknown)
+ }.should raise_error(Whois::AllocationUnknown)
end
end
@@ -194,6 +194,15 @@
Whois::Server.guess("::192.168.1.1") == Whois::Server.factory(:ipv6, "::192.168.1.1", "whois.test")
end
end
+
+ # https://github.com/weppos/whois/issues/174
+ it "rescues IPAddr ArgumentError" do
+ with_definitions do
+ lambda {
+ Whois::Server.guess("f53")
+ }.should raise_error(Whois::AllocationUnknown)
+ end
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.