Class: Cymru::IPAddress
Constant Summary collapse
- ORIGIN =
"origin.asn.cymru.com"
- ORIGIN6 =
"origin6.asn.cymru.com"
- BOGON =
"bogons.cymru.com"
Instance Attribute Summary collapse
-
#allocdate ⇒ Object
readonly
Returns the value of attribute allocdate.
-
#asname ⇒ Object
readonly
Returns the value of attribute asname.
-
#asnum ⇒ Object
readonly
Returns the value of attribute asnum.
-
#cidr ⇒ Object
readonly
Returns the value of attribute cidr.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
-
#initialize ⇒ IPAddress
constructor
A new instance of IPAddress.
- #whois(addr) ⇒ Object (also: #lookup)
Methods included from DNSquery
Constructor Details
#initialize ⇒ IPAddress
Returns a new instance of IPAddress.
35 36 |
# File 'lib/cymruwhois.rb', line 35 def initialize end |
Instance Attribute Details
#allocdate ⇒ Object (readonly)
Returns the value of attribute allocdate.
29 30 31 |
# File 'lib/cymruwhois.rb', line 29 def allocdate @allocdate end |
#asname ⇒ Object (readonly)
Returns the value of attribute asname.
29 30 31 |
# File 'lib/cymruwhois.rb', line 29 def asname @asname end |
#asnum ⇒ Object (readonly)
Returns the value of attribute asnum.
29 30 31 |
# File 'lib/cymruwhois.rb', line 29 def asnum @asnum end |
#cidr ⇒ Object (readonly)
Returns the value of attribute cidr.
29 30 31 |
# File 'lib/cymruwhois.rb', line 29 def cidr @cidr end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
29 30 31 |
# File 'lib/cymruwhois.rb', line 29 def country @country end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
29 30 31 |
# File 'lib/cymruwhois.rb', line 29 def registry @registry end |
Instance Method Details
#whois(addr) ⇒ Object Also known as: lookup
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cymruwhois.rb', line 38 def whois(addr) ip = IPAddr.new(addr) if ip.ipv4? revdns = ip.reverse.sub("in-addr.arpa", ORIGIN) elsif ip.ipv6? revdns = ip.reverse.sub("ip6.arpa", ORIGIN6) end ansip = intxt(revdns) @asnum = ansip[0] @cidr = ansip[1] @country = ansip[2] @registry = ansip[3] @allocdate = ansip[4] # to address the multi ASN issue for the same IP Block asparam = ansip[0].split ansasnum = Cymru::ASNumber.new ansasnum.whois(asparam[0]) @asname = ansasnum.asname ansip << @asname end |