Parsing responses for IP queries
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:
- some have OrgName, some have descr; lots of people don't fill descr out the way they're supposed to, so you end up with awful entries like "Shared Webhosting". Not much you can do about crummy data though.
- some have CIDR instead of netrange, so you'll likely need to expand that. Expect some strangely formatted CIDRs though (like 192.12/16, usually from LACNIC)
- some of the RIRs throttle; not sure if you're handling that in the lib today or punting it up to an application concern
- depending on what servers you hit, you can get some annoyingly useless responses. For example, a given IP that's been suballocated might get the final allocation you're interested in, or you might just see that it's been assigned to eg. APNIC
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.