Class: MonoVM::Whois::Referral::Follower
- Inherits:
-
Object
- Object
- MonoVM::Whois::Referral::Follower
- Defined in:
- lib/monovm/whois/referral/follower.rb
Overview
Chases a thin registry's pointer to the registrar's own WHOIS server.
Verisign and the other thin registries hold almost nothing: query .com and
the answer is a domain name, a status, nameservers, and a +Registrar WHOIS
Server+ line pointing at whoever sold it. The registrant, the contact details
and often the accurate expiry date are only on that second server. A client
that stops at the first answer reports the thin record as the whole truth.
One deliberate constraint: a referral enriches the record, never the verdict. The registry is authoritative about whether a name exists, and a registrar's server that is down, rate-limiting or simply wrong must not be able to turn a registered domain into an available one.
Constant Summary collapse
- SKIP_HOSTS =
Registrars that answer but say nothing useful, or point in a circle. Following these costs a round trip and a rate-limit slot for no data.
[ "whois.iana.org", "whois.markmonitor.com", "not.applicable", "none" ].freeze
Instance Attribute Summary collapse
-
#max_hops ⇒ Object
readonly
Returns the value of attribute max_hops.
-
#transport_factory ⇒ Object
readonly
Returns the value of attribute transport_factory.
Instance Method Summary collapse
-
#follow(response:, record:, query:) ⇒ Response?
The registrar's answer, or nil when there is no referral to follow or following it failed.
-
#initialize(transport_factory:, max_hops: 1) ⇒ Follower
constructor
A new instance of Follower.
Constructor Details
#initialize(transport_factory:, max_hops: 1) ⇒ Follower
Returns a new instance of Follower.
35 36 37 38 |
# File 'lib/monovm/whois/referral/follower.rb', line 35 def initialize(transport_factory:, max_hops: 1) @transport_factory = transport_factory @max_hops = max_hops end |
Instance Attribute Details
#max_hops ⇒ Object (readonly)
Returns the value of attribute max_hops.
31 32 33 |
# File 'lib/monovm/whois/referral/follower.rb', line 31 def max_hops @max_hops end |
#transport_factory ⇒ Object (readonly)
Returns the value of attribute transport_factory.
31 32 33 |
# File 'lib/monovm/whois/referral/follower.rb', line 31 def transport_factory @transport_factory end |
Instance Method Details
#follow(response:, record:, query:) ⇒ Response?
Returns the registrar's answer, or nil when there is no referral to follow or following it failed.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/monovm/whois/referral/follower.rb', line 45 def follow(response:, record:, query:) return nil unless max_hops.positive? return nil unless response.whois? host = referral_host(record, response) return nil if host.nil? fetch(Endpoint.parse("socket://#{host}"), query) rescue DefinitionsError # The referral was not a usable host name; keep the registry's answer. nil end |