whois-parser icon indicating copy to clipboard operation
whois-parser copied to clipboard

Parser apparently doesnt work for Ipv4 addresses

Open maaz-munir opened this issue 1 year ago • 3 comments

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.

maaz-munir avatar Jul 28 '24 11:07 maaz-munir

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.

jarthod avatar Jul 28 '24 12:07 jarthod

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

maaz-munir avatar Jul 29 '24 07:07 maaz-munir

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 :)

jarthod avatar Jul 29 '24 10:07 jarthod