Class: MonoVM::Whois::Parser::IcannRdd
- Defined in:
- lib/monovm/whois/parser/icann_rdd.rb
Overview
The ICANN Registrar Data Directory format used by gTLD registries.
Structurally it is KeyValue, so almost everything is inherited. What earns a
subclass is that this format carries the same fact twice and the two copies
disagree: a .com record holds both a Registry Expiry Date and a
Registrar Registration Expiration Date, and the registrar's copy is
frequently stale. The registry is authoritative, so it wins here explicitly
rather than by luck of alias ordering.
It also drops the >>> Last update of WHOIS database trailer, which is a
timestamp for the database rather than for the domain and otherwise lands in
Record#updated_on.
Constant Summary collapse
- SIGNATURE_KEYS =
Keys that only this format uses; two of them together is a confident match.
[ "registry domain id", "registrar whois server", "registrar iana id", "registry expiry date" ].freeze
- TRAILER =
/>>>\s*Last update of (?:the )?WHOIS database.*$/i
Constants inherited from KeyValue
KeyValue::ALIASES, KeyValue::CONTACT_ATTRIBUTES, KeyValue::CONTACT_ROLES, KeyValue::LINE, KeyValue::MULTI
Constants inherited from Base
Base::DATE_FORMATS, Base::PLAUSIBLE_YEARS
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#applicable?(response) ⇒ Boolean
31 32 33 34 35 36 |
# File 'lib/monovm/whois/parser/icann_rdd.rb', line 31 def applicable?(response) return false if response.json? text = response.text.downcase SIGNATURE_KEYS.count { |key| text.include?("#{key}:") } >= 2 end |
#parse(response) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/monovm/whois/parser/icann_rdd.rb', line 38 def parse(response) record = super # The registry's expiry date is authoritative; only fall back to the # registrar's if the registry did not supply one. expires = parse_time(record["registry expiry date"]) || record.expires_on Record.new( domain: record.domain, registry_id: record.registry_id, registrar: record.registrar, registrar_whois_server: record.registrar_whois_server, registrar_url: record.registrar_url, registrar_iana_id: record.registrar_iana_id, registrant: record.registrant, statuses: record.statuses.map { |status| strip_epp_url(status) }, nameservers: record.nameservers, created_on: record.created_on, updated_on: record.updated_on, expires_on: expires, dnssec: record.dnssec, contacts: record.contacts, fields: record.fields, source: name ) end |