Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Apr 4, 2013

Conversation

linrock
Copy link
Contributor

@linrock linrock commented Apr 4, 2013

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
Copy link
Contributor Author

linrock commented Apr 4, 2013

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

@@ -26,6 +26,7 @@ class Arin < Base
# @return [void]
#
def request(string)
string = "+ z #{string}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense - I changed it.

@linrock
Copy link
Contributor Author

linrock commented Apr 4, 2013

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

@weppos
Copy link
Owner

weppos commented Apr 4, 2013

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

Good idea! 👏

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])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha it's alright. Updated again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry, it's fine. If all the patches requests would be like this
would be a wonderful world.

Thanks again!

On Thu, Apr 4, 2013 at 12:36 PM, Linmiao Xu notifications@github.comwrote:

In 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])
    

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


Reply to this email directly or view it on GitHubhttps://github.com//pull/220/files#r3652781
.

Simone Carletti
Passionate programmer and dive instructor

http://www.simonecarletti.com/
Twitter: @weppos https://twitter.com/weppos - Facebook: simone.io

@ghost ghost assigned weppos Apr 4, 2013
weppos added a commit that referenced this pull request Apr 4, 2013
Send additional parameters for ARIN queries (fixes #10).
@weppos weppos merged commit cbb2e73 into weppos:master Apr 4, 2013
weppos added a commit that referenced this pull request Apr 4, 2013
weppos added a commit that referenced this pull request Apr 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants