weppos / whois-parser

An intelligent — pure Ruby — WHOIS parser.
https://whoisrb.org
MIT License
98 stars 102 forks source link

Parser apparently doesnt work for Ipv4 addresses #162

Open maaz-munir opened 4 months ago

maaz-munir commented 4 months ago

Is there not a parser for ipv4 whois records?

This is the code i am currently trying to run to output the properties returned from the parser.

client = Whois::Client.new(:timeout => 40)
domain = client.lookup("1.1.1.1")
p = domain.parser
msg = {}    
puts "Parser class: #{p.class}"

Whois::Parser::PROPERTIES.each do |x_prop|
  begin
     value = p.send(x_prop)
      puts "Property #{x_prop}: #{value.inspect}"
      msg[x_prop] = value if value
  rescue => e
    puts "Error accessing #{x_prop}: #{e.message}"
  end
end 

puts "Final msg: #{msg.inspect}"

And it returns unable to return a parser for property [disclaimer(example)]

This works fine for domains.

jarthod commented 4 months ago

For IPs it would be more robust to use RDAP instead anyway (see https://github.com/jarthod/rdap) As the whois-parser project will never be able to support and maintain all whois server formats in existence. And unlike domains, all IPs are supported by RDAP already.

maaz-munir commented 4 months ago

Thanks! I'm still new to this, i'll look into the RDAP protocol. But in theory shouldn't there be only 5 WHOIS server formats - corresponding to the relevant RIRs? Or am I missing something

jarthod commented 4 months ago

I think you are right, but that's still 5 more parsers to maintain. If you want to contribute them feel free but @weppos stopped maintaining this gem so you can't get the fix upstream AFAIK. I maintain a fork in https://github.com/jarthod/whois-parser which is much more up-to-date, but I personally use it as fallback only for TLD which do not support RDAP yet. So I believe for a use-case (IP only) which is already 100% supported by RDAP (I haven't tested all IPs but I think it is), it would be much easier and more reliable to use RDAP (you get structured and machine-readable JSON instead of text intended for human eyes).

Nonetheless if for some reason you prefer to implement the whois parser for RIR IPs, I'll happily accept a PR in my fork :)