Permalink
Browse files

Handle ReferralServer directive in ARIN whois queries (closes GH-204, c…

…loses GH-37)
  • Loading branch information...
2 parents fd90e6e + 06ab8f7 commit d6a13c54b4a52c13caf77c3947d30dd8642d77f9 @weppos committed Mar 29, 2013
View
@@ -145,7 +145,8 @@
"host": "whois.apnic.net"
},
"0.0.0.0/1": {
- "host": "whois.arin.net"
+ "host": "whois.arin.net",
+ "adapter": "arin"
},
"133.0.0.0/8": {
"host": "whois.nic.ad.jp"
@@ -163,7 +164,8 @@
"host": "whois.ripe.net"
},
"141.86.0.0/16": {
- "host": "whois.arin.net"
+ "host": "whois.arin.net",
+ "adapter": "arin"
},
"141.64.0.0/11": {
"host": "whois.ripe.net"
@@ -364,16 +366,19 @@
"host": "whois.lacnic.net"
},
"128.0.0.0/2": {
- "host": "whois.arin.net"
+ "host": "whois.arin.net",
+ "adapter": "arin"
},
"192.71.0.0/16": {
"host": "whois.ripe.net"
},
"192.72.253.0/24": {
- "host": "whois.arin.net"
+ "host": "whois.arin.net",
+ "adapter": "arin"
},
"192.72.254.0/24": {
- "host": "whois.arin.net"
+ "host": "whois.arin.net",
+ "adapter": "arin"
},
"192.72.0.0/16": {
"host": "whois.apnic.net"
@@ -397,7 +402,8 @@
"host": "whois.ripe.net"
},
"192.0.0.0/8": {
- "host": "whois.arin.net"
+ "host": "whois.arin.net",
+ "adapter": "arin"
},
"193.0.0.0/8": {
"host": "whois.ripe.net"
@@ -409,7 +415,8 @@
"host": "whois.afrinic.net"
},
"198.0.0.0/7": {
- "host": "whois.arin.net"
+ "host": "whois.arin.net",
+ "adapter": "arin"
},
"200.17.0.0/16": {
"host": "whois.nic.br"
@@ -505,10 +512,12 @@
"host": "rwhois.gin.ntt.net"
},
"204.0.0.0/6": {
- "host": "whois.arin.net"
+ "host": "whois.arin.net",
+ "adapter": "arin"
},
"208.0.0.0/7": {
- "host": "whois.arin.net"
+ "host": "whois.arin.net",
+ "adapter": "arin"
},
"209.94.192.0/19": {
"host": "whois.lacnic.net"
@@ -634,10 +643,12 @@
"host": "whois.ripe.net"
},
"214.0.0.0/7": {
- "host": "whois.arin.net"
+ "host": "whois.arin.net",
+ "adapter": "arin"
},
"216.0.0.0/8": {
- "host": "whois.arin.net"
+ "host": "whois.arin.net",
+ "adapter": "arin"
},
"217.0.0.0/8": {
"host": "whois.ripe.net"
@@ -720,4 +731,4 @@
"220.0.0.0/6": {
"host": "whois.apnic.net"
}
-}
+}
View
@@ -25,6 +25,8 @@ class Server
# WHOIS server adapters. Each adapter is a subclass of {Whois::Server::Adapters::Base},
# customized to handle WHOIS queries for a type or a group of servers.
module Adapters
+ autoload :Base, "whois/server/adapters/base"
+ autoload :Arin, "whois/server/adapters/arin"
autoload :Arpa, "whois/server/adapters/arpa"
autoload :Afilias, "whois/server/adapters/afilias"
autoload :Formatted, "whois/server/adapters/formatted"
@@ -0,0 +1,52 @@
+#--
+# Ruby Whois
+#
+# An intelligent pure Ruby WHOIS client and parser.
+#
+# Copyright (c) 2009-2013 Simone Carletti <weppos@weppos.net>
+#++
+
+
+module Whois
+ class Server
+ module Adapters
+
+ #
+ # = Arin Adapter
+ #
+ # Provides ability to query Arin WHOIS interfaces.
+ #
+ class Arin < Base
+
+ # Executes a WHOIS query to the Arin WHOIS interface,
+ # resolving any intermediate referral,
+ # and appends the response to the client buffer.
+ #
+ # @param [String] string
+ # @return [void]
+ #
+ def request(string)
+ response = query_the_socket(string, host)
+ buffer_append response, host
+
+ if options[:referral] != false && (referral = extract_referral(response))
+ response = query_the_socket(string, referral[:host], referral[:port])
+ buffer_append(response, referral[:host])
+ end
+ end
+
+ private
+
+ def extract_referral(response)
+ return unless response =~ /ReferralServer:\s*r?whois:\/\/([\w\.]+):?(\d+)/
+ {
+ host: $1,
+ port: $2 ? $2.to_i : nil
+ }
+ end
+
+ end
+
+ end
+ end
+end
@@ -0,0 +1,52 @@
+#
+# The following results may also be obtained via:
+# http://whois.arin.net/rest/nets;q=4.2.2.1?showDetails=true&showARIN=false&ext=netref2
+#
+
+NetRange: 4.0.0.0 - 4.255.255.255
+CIDR: 4.0.0.0/8
+OriginAS:
+NetName: LVLT-ORG-4-8
+NetHandle: NET-4-0-0-0-1
+Parent:
+NetType: Direct Allocation
+RegDate: 1992-12-01
+Updated: 2012-02-24
+Ref: http://whois.arin.net/rest/net/NET-4-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
+
+OrgTechHandle: IPADD5-ARIN
+OrgTechName: ipaddressing
+OrgTechPhone: +1-877-453-8353
+OrgTechEmail: ipaddressing@level3.com
+OrgTechRef: http://whois.arin.net/rest/poc/IPADD5-ARIN
+
+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
+
+OrgAbuseHandle: APL8-ARIN
+OrgAbuseName: Abuse POC LVLT
+OrgAbusePhone: +1-877-453-8353
+OrgAbuseEmail: security@level3.com
+OrgAbuseRef: http://whois.arin.net/rest/poc/APL8-ARIN
+
+#
+# ARIN WHOIS data and services are subject to the Terms of Use
+# available at: https://www.arin.net/whois_tou.html
+#
+
@@ -0,0 +1,62 @@
+#
+# Query terms are ambiguous. The query is assumed to be:
+# "n 69.65.39.166"
+#
+# Use "?" to get help.
+#
+
+#
+# The following results may also be obtained via:
+# http://whois.arin.net/rest/nets;q=69.65.39.166?showDetails=true&showARIN=false&ext=netref2
+#
+
+NetRange: 69.65.0.0 - 69.65.63.255
+CIDR: 69.65.0.0/18
+OriginAS:
+NetName: IPNAP
+NetHandle: NET-69-65-0-0-1
+Parent: NET-69-0-0-0-0
+NetType: Direct Allocation
+Comment: www.gigenet.com
+RegDate: 2003-07-30
+Updated: 2012-03-02
+Ref: http://whois.arin.net/rest/net/NET-69-65-0-0-1
+
+OrgName: GigeNET
+OrgId: DMPL
+Address: 545 E Algonquin Rd
+Address: Suite D
+City: Arlington Heights
+StateProv: IL
+PostalCode: 60005
+Country: US
+RegDate: 2011-03-04
+Updated: 2011-06-23
+Comment: http://www.gigenet.com
+Ref: http://whois.arin.net/rest/org/DMPL
+
+ReferralServer: rwhois://rwhois.servernap.net:4321
+
+OrgTechHandle: IPADM152-ARIN
+OrgTechName: IP Administrator
+OrgTechPhone: +1-800-561-2656
+OrgTechEmail: ip-admin@coloquest.com
+OrgTechRef: http://whois.arin.net/rest/poc/IPADM152-ARIN
+
+OrgNOCHandle: IPADM152-ARIN
+OrgNOCName: IP Administrator
+OrgNOCPhone: +1-800-561-2656
+OrgNOCEmail: ip-admin@coloquest.com
+OrgNOCRef: http://whois.arin.net/rest/poc/IPADM152-ARIN
+
+OrgAbuseHandle: ABUSE2935-ARIN
+OrgAbuseName: Abuse Department
+OrgAbusePhone: +1-800-561-2656
+OrgAbuseEmail: abuse@gigenet.com
+OrgAbuseRef: http://whois.arin.net/rest/poc/ABUSE2935-ARIN
+
+#
+# ARIN WHOIS data and services are subject to the Terms of Use
+# available at: https://www.arin.net/whois_tou.html
+#
+
@@ -0,0 +1,56 @@
+#
+# Query terms are ambiguous. The query is assumed to be:
+# "n 130.66.76.222"
+#
+# Use "?" to get help.
+#
+
+#
+# The following results may also be obtained via:
+# http://whois.arin.net/rest/nets;q=130.66.76.222?showDetails=true&showARIN=false&ext=netref2
+#
+
+NetRange: 130.66.0.0 - 130.67.255.255
+CIDR: 130.66.0.0/15
+OriginAS:
+NetName: RIPE-ERX-130-66-0-0
+NetHandle: NET-130-66-0-0-1
+Parent: NET-130-0-0-0-0
+NetType: Early Registrations, Transferred to RIPE NCC
+Comment: These addresses have been further assigned to users in
+Comment: the RIPE NCC region. Contact information can be found in
+Comment: the RIPE database at http://www.ripe.net/whois
+RegDate: 2003-11-12
+Updated: 2003-11-12
+Ref: http://whois.arin.net/rest/net/NET-130-66-0-0-1
+
+OrgName: RIPE Network Coordination Centre
+OrgId: RIPE
+Address: P.O. Box 10096
+City: Amsterdam
+StateProv:
+PostalCode: 1001EB
+Country: NL
+RegDate:
+Updated: 2011-09-24
+Ref: http://whois.arin.net/rest/org/RIPE
+
+ReferralServer: whois://whois.ripe.net:43
+
+OrgAbuseHandle: RNO29-ARIN
+OrgAbuseName: RIPE NCC Operations
+OrgAbusePhone: +31 20 535 4444
+OrgAbuseEmail: hostmaster@ripe.net
+OrgAbuseRef: http://whois.arin.net/rest/poc/RNO29-ARIN
+
+OrgTechHandle: RNO29-ARIN
+OrgTechName: RIPE NCC Operations
+OrgTechPhone: +31 20 535 4444
+OrgTechEmail: hostmaster@ripe.net
+OrgTechRef: http://whois.arin.net/rest/poc/RNO29-ARIN
+
+#
+# ARIN WHOIS data and services are subject to the Terms of Use
+# available at: https://www.arin.net/whois_tou.html
+#
+
Oops, something went wrong.

0 comments on commit d6a13c5

Please sign in to comment.