Class: Mihari::Clients::Whois
- Inherits:
-
Object
- Object
- Mihari::Clients::Whois
- Defined in:
- lib/mihari/clients/whois.rb
Overview
Whois client
Instance Attribute Summary collapse
- #client ⇒ ::Whois::Client readonly
- #timeout ⇒ Integer? readonly
Instance Method Summary collapse
-
#initialize(timeout: nil) ⇒ Whois
constructor
A new instance of Whois.
-
#lookup(domain) ⇒ Object
Query IAIA Whois API.
Constructor Details
#initialize(timeout: nil) ⇒ Whois
Returns a new instance of Whois.
20 21 22 23 24 25 26 27 28 |
# File 'lib/mihari/clients/whois.rb', line 20 def initialize(timeout: nil) @timeout = timeout @client = lambda do return ::Whois::Client.new if timeout.nil? ::Whois::Client.new(timeout:) end.call end |
Instance Attribute Details
#client ⇒ ::Whois::Client (readonly)
15 16 17 |
# File 'lib/mihari/clients/whois.rb', line 15 def client @client end |
#timeout ⇒ Integer? (readonly)
12 13 14 |
# File 'lib/mihari/clients/whois.rb', line 12 def timeout @timeout end |
Instance Method Details
#lookup(domain) ⇒ Object
Query IAIA Whois API
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mihari/clients/whois.rb', line 36 def lookup(domain) record = client.lookup(domain) return if record.parser.available? Models::WhoisRecord.new( domain:, created_on: get_created_on(record.parser), updated_on: get_updated_on(record.parser), expires_on: get_expires_on(record.parser), registrar: get_registrar(record.parser), contacts: get_contacts(record.parser) ) end |