weppos / whois

An intelligent — pure Ruby — WHOIS client and parser.
https://whoisrb.org
MIT License
1.11k stars 282 forks source link

Whois::ConnectionError: SocketError: getaddrinfo: nodename nor servname provided, or not known #641

Closed rgaufman closed 2 years ago

rgaufman commented 2 years ago

I'm using whois (5.0.2)

tether-it(dev)> Whois::Client.new(timeout: 30).lookup('104.222.43.19')
Whois::ConnectionError: SocketError: getaddrinfo: nodename nor servname provided, or not known
from /opt/homebrew/lib/ruby/gems/3.0.0/gems/whois-5.0.2/lib/whois/server/socket_handler.rb:42:in `rescue in call'
Caused by SocketError: getaddrinfo: nodename nor servname provided, or not known
from /opt/homebrew/lib/ruby/gems/3.0.0/gems/whois-5.0.2/lib/whois/server/socket_handler.rb:57:in `initialize'
tether-it(dev)>

Any ideas?

weppos commented 2 years ago

The response from Arin contains a referral that is not responding:

getaddrinfo(rwhois.coloup.com): nodename nor servname provided, or not known

You can see the partial response by making a small change in the code:

diff --git a/lib/whois/server/adapters/base.rb b/lib/whois/server/adapters/base.rb
index 0df22bad..1d43b573 100644
--- a/lib/whois/server/adapters/base.rb
+++ b/lib/whois/server/adapters/base.rb
@@ -137,6 +137,8 @@ module Whois
           @buffer ||= []
           yield(@buffer)
           @buffer.dup
+        rescue
+          p @buffer
         ensure
           @buffer.clear
         end
irb(main):001:0> Whois::Server.guess('104.222.43.19')
=> #<Whois::Server::Adapters::Arin:0x00007fba50907420 @allocation="0.0.0.0/1", @host="whois.arin.net", @options={}, @type=:ipv4>
irb(main):002:0> Whois::Client.new(timeout: 30).lookup('104.222.43.19')
[#<struct Whois::Record::Part body="\n#\n# ARIN WHOIS data and services are subject to the Terms of Use\n# available at: https://www.arin.net/resources/registry/whois/tou/\n#\n# If you see inaccuracies in the results, please report at\n# https://www.arin.net/resources/registry/whois/inaccuracy_reporting/\n#\n# Copyright 1997-2021, American Registry for Internet Numbers, Ltd.\n#\n\n\nNetRange:       104.222.32.0 - 104.222.47.255\nCIDR:           104.222.32.0/20\nNetName:        COLOUP\nNetHandle:      NET-104-222-32-0-1\nParent:         NET104 (NET-104-0-0-0-0)\nNetType:        Direct Allocation\nOriginAS:       AS19084\nOrganization:   ColoUp (SL-311)\nRegDate:        2014-10-13\nUpdated:        2014-10-13\nRef:            https://rdap.arin.net/registry/ip/104.222.32.0\n\n\nOrgName:        ColoUp\nOrgId:          SL-311\nAddress:        One Commerce Center - 1201 Orange St. #600\nCity:           Wilmington\nStateProv:      DE\nPostalCode:     19899\nCountry:        US\nRegDate:        2013-09-30\nUpdated:        2017-12-15\nRef:            https://rdap.arin.net/registry/entity/SL-311\n\nReferralServer:  rwhois://rwhois.coloup.com:4321\n\nOrgAbuseHandle: ABUSE4672-ARIN\nOrgAbuseName:   Abuse\nOrgAbusePhone:  +1-302-261-5353 \nOrgAbuseEmail:  abuse@coloup.com\nOrgAbuseRef:    https://rdap.arin.net/registry/entity/ABUSE4672-ARIN\n\nOrgTechHandle: NETWO6762-ARIN\nOrgTechName:   Network Operations\nOrgTechPhone:  +1-302-261-5353 \nOrgTechEmail:  info@coloup.com\nOrgTechRef:    https://rdap.arin.net/registry/entity/NETWO6762-ARIN\n\nOrgNOCHandle: NETWO6762-ARIN\nOrgNOCName:   Network Operations\nOrgNOCPhone:  +1-302-261-5353 \nOrgNOCEmail:  info@coloup.com\nOrgNOCRef:    https://rdap.arin.net/registry/entity/NETWO6762-ARIN\n\n\n#\n# ARIN WHOIS data and services are subject to the Terms of Use\n# available at: https://www.arin.net/resources/registry/whois/tou/\n#\n# If you see inaccuracies in the results, please report at\n# https://www.arin.net/resources/registry/whois/inaccuracy_reporting/\n#\n# Copyright 1997-2021, American Registry for Internet Numbers, Ltd.\n#\n\n", host="whois.arin.net">]
=> ""

Related to https://github.com/weppos/whois/issues/186