Send additional parameters for ARIN queries (fixes #10). #220

Merged
merged 2 commits into from Apr 4, 2013

Projects

None yet

2 participants

@linrock

Without sending additional parameters, ARIN sometimes doesn't return a full response (see #10). For example:

>>> ./bin/ruby-whois 8.8.8.8

#
# Query terms are ambiguous.  The query is assumed to be:
#     "n 8.8.8.8"
#
# Use "?" to get help.
#

#
# The following results may also be obtained via:
# http://whois.arin.net/rest/nets;q=8.8.8.8?showDetails=true&showARIN=false&ext=netref2
#

Level 3 Communications, Inc. LVLT-ORG-8-8 (NET-8-0-0-0-1) 8.0.0.0 - 8.255.255.255
Google Incorporated LVLT-GOOGL-1-8-8-8 (NET-8-8-8-0-1) 8.8.8.0 - 8.8.8.255


#
# ARIN WHOIS data and services are subject to the Terms of Use
# available at: https://www.arin.net/whois_tou.html
#

Sending "n +" as the query parameters should give a full response. Here's the same query, but prepending "n +":

>>> ./bin/ruby-whois 8.8.8.8

#
# The following results may also be obtained via:
# http://whois.arin.net/rest/nets;q=8.8.8.8?showDetails=true&showARIN=false&ext=netref2
#


# start

NetRange:       8.0.0.0 - 8.255.255.255
CIDR:           8.0.0.0/8
OriginAS:
NetName:        LVLT-ORG-8-8
NetHandle:      NET-8-0-0-0-1
Parent:
NetType:        Direct Allocation
RegDate:        1992-12-01
Updated:        2012-02-24
Ref:            http://whois.arin.net/rest/net/NET-8-0-0-0-1


OrgName:        Level 3 Communications, Inc.
OrgId:          LVLT
Address:        1025 Eldorado Blvd.
City:           Broomfield
StateProv:      CO
PostalCode:     80021
Country:        US
RegDate:        1998-05-22
Updated:        2012-01-30
Comment:        ADDRESSES WITHIN THIS BLOCK ARE NON-PORTABLE
Ref:            http://whois.arin.net/rest/org/LVLT

OrgNOCHandle: NOCSU27-ARIN
OrgNOCName:   NOC Support
OrgNOCPhone:  +1-877-453-8353
OrgNOCEmail:  noc.coreip@level3.com
OrgNOCRef:    http://whois.arin.net/rest/poc/NOCSU27-ARIN

OrgTechHandle: IPADD5-ARIN
OrgTechName:   ipaddressing
OrgTechPhone:  +1-877-453-8353
OrgTechEmail:  ipaddressing@level3.com
OrgTechRef:    http://whois.arin.net/rest/poc/IPADD5-ARIN

OrgAbuseHandle: APL8-ARIN
OrgAbuseName:   Abuse POC LVLT
OrgAbusePhone:  +1-877-453-8353
OrgAbuseEmail:  abuse@level3.com
OrgAbuseRef:    http://whois.arin.net/rest/poc/APL8-ARIN

# end


# start

NetRange:       8.8.8.0 - 8.8.8.255
CIDR:           8.8.8.0/24
OriginAS:
NetName:        LVLT-GOOGL-1-8-8-8
NetHandle:      NET-8-8-8-0-1
Parent:         NET-8-0-0-0-1
NetType:        Reassigned
RegDate:        2009-09-21
Updated:        2009-09-21
Ref:            http://whois.arin.net/rest/net/NET-8-8-8-0-1

OrgName:        Google Incorporated
OrgId:          GOOGL-1
Address:        Google Information Technology
Address:        1600 Amphitheatre Parkway
City:           Mountain View
StateProv:      CA
PostalCode:     94043
Country:        US
RegDate:        2005-12-06
Updated:        2011-09-24
Ref:            http://whois.arin.net/rest/org/GOOGL-1

OrgAbuseHandle: ZG39-ARIN
OrgAbuseName:   Google Inc
OrgAbusePhone:  +1-650-253-0000
OrgAbuseEmail:  arin-contact@google.com
OrgAbuseRef:    http://whois.arin.net/rest/poc/ZG39-ARIN

OrgAbuseHandle: MAX1-ARIN
OrgAbuseName:   AXELROD, Michael
OrgAbusePhone:  +1-650-253-0000
OrgAbuseEmail:  axelrod@google.com
OrgAbuseRef:    http://whois.arin.net/rest/poc/MAX1-ARIN

OrgTechHandle: MAX1-ARIN
OrgTechName:   AXELROD, Michael
OrgTechPhone:  +1-650-253-0000
OrgTechEmail:  axelrod@google.com
OrgTechRef:    http://whois.arin.net/rest/poc/MAX1-ARIN

OrgTechHandle: ZG39-ARIN
OrgTechName:   Google Inc
OrgTechPhone:  +1-650-253-0000
OrgTechEmail:  arin-contact@google.com
OrgTechRef:    http://whois.arin.net/rest/poc/ZG39-ARIN

OrgTechHandle: NEC10-ARIN
OrgTechName:   Network Engineering Corp
OrgTechPhone:  +1-650-214-6513
OrgTechEmail:  ir-contact-netops-corp@google.com
OrgTechRef:    http://whois.arin.net/rest/poc/NEC10-ARIN

OrgAbuseHandle: NEC10-ARIN
OrgAbuseName:   Network Engineering Corp
OrgAbusePhone:  +1-650-214-6513
OrgAbuseEmail:  ir-contact-netops-corp@google.com
OrgAbuseRef:    http://whois.arin.net/rest/poc/NEC10-ARIN

OrgTechHandle: KKC9-ARIN
OrgTechName:   Chittimaneni, Kiran Kumar
OrgTechPhone:  +1-650-253-3000
OrgTechEmail:  kk@google.com
OrgTechRef:    http://whois.arin.net/rest/poc/KKC9-ARIN

OrgAbuseHandle: KKC9-ARIN
OrgAbuseName:   Chittimaneni, Kiran Kumar
OrgAbusePhone:  +1-650-253-3000
OrgAbuseEmail:  kk@google.com
OrgAbuseRef:    http://whois.arin.net/rest/poc/KKC9-ARIN

# end


#
# ARIN WHOIS data and services are subject to the Terms of Use
# available at: https://www.arin.net/whois_tou.html
#

From the ARIN help info:

Query-by-record-type:
---------------------
To limit your query to a specific record type, include one of the following
flags:
      n       Network address space
      r       CIDRized network space
      d       Delegations
      a       Autonomous systems
      p       Points-of-contact
      o       Organizations
      c       End-user customers
      e       Points-of-contact, Organizations, End-user customers
      z       All of the above

Display flags:
--------------
To modify the way that the query results display, include one of the
following flags:
      +       FULL output shows detailed display for EACH match
      -       LIST output shows summary only, even if single match
              returned
@linrock

Hmm, I'll have to update the tests to account for this.

@weppos weppos and 1 other commented on an outdated diff Apr 4, 2013
lib/whois/server/adapters/arin.rb
@@ -26,6 +26,7 @@ class Arin < Base
# @return [void]
#
def request(string)
+ string = "+ z #{string}"
@weppos
weppos Apr 4, 2013

Unless you need it later, I would suggest to pass the modified string directly to the method call.

response = query_the_socket("+ z #{string}", host)
@linrock
linrock Apr 4, 2013

Makes sense - I changed it.

@linrock

I changed the parameters being sent to "n +" just to be consistent with debian whois.

@weppos
Owner

I changed the parameters being sent to "n +" just to be consistent with debian whois.

Good idea! 👏

@weppos weppos and 1 other commented on an outdated diff Apr 4, 2013
lib/whois/server/adapters/arin.rb
buffer_append response, host
if options[:referral] != false && (referral = extract_referral(response))
- response = query_the_socket(string, referral[:host], referral[:port])
+ response = query_the_socket("n + #{string}", referral[:host], referral[:port])
@weppos
weppos Apr 4, 2013

Actually, I didn't notice it was used twice. In this case I would suggest

def request(string)
  query = "n + #{string}"

Then you can use the query variable. The reason for this, is that I normally tend to avoid replacing the argument (that's the reason why I didn't like string = "n + #{string}")

Sorry for the back and forth.

@linrock
linrock Apr 4, 2013

Haha it's alright. Updated again.

@linrock
linrock Apr 4, 2013

Oops, sorry I misread about using the query variable. I don't normally have a preference, but I'll be mindful next time.

@weppos
weppos Apr 4, 2013
@weppos weppos was assigned Apr 4, 2013
@weppos weppos merged commit cbb2e73 into weppos:master Apr 4, 2013

1 check passed

Details default The Travis build passed
@weppos weppos added a commit that referenced this pull request Apr 4, 2013
@weppos Don't override argument (GH-220) b84d80f
@weppos weppos added a commit that referenced this pull request Apr 4, 2013
@weppos CHANGELOG for GH-220, GH-10 81b7d25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment