weppos / whois

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

Parsing responses for IP queries #292

Open elindsey opened 10 years ago

elindsey commented 10 years ago

Today when I query for an IP I seem to just get the hostname and a giant body blob back. It'd be great if that could be broken down into common fields, similar to the domain lookups.

IP whois data is a bit of a mess. This is the only lib I've seen that does a decent job of parsing out a common subset (though the API is atrocious); it might be a useful reference - http://search.cpan.org/~romm/Net-Whois-IANA-0.41/lib/Net/Whois/IANA.pm

A few gotchas that could be relevant:

mgold commented 10 years ago

I too am interested in the CIDR for an IP query. It shouldn't be too hard to add :cidr = nil or something to the parser parent classes, and then override that when information is available. An IPAddr object seems like a useful non-nil value. Its constructor can handle a CIDR string (as long as all 4 octets are there) but not a netrange (workaround). Sometimes that's all that's available; lookup 1.164.0.0.

There's certainly a lot of other information that can be extracted but I'd rather have CIDR working in many cases than never get the general solution online.