Class: MonoVM::Whois::Checker
- Inherits:
-
Object
- Object
- MonoVM::Whois::Checker
- Defined in:
- lib/monovm/whois/checker.rb
Overview
Checks many domains, and expands a bare name across popular TLDs.
Two jobs the single-domain Client deliberately does not do. Given "monovm"
with no TLD it tries .com, .net, .org and .info; given a list it works
through it concurrently.
Concurrency here is safe only because Transport::Middleware::Throttle sits
underneath it: eight threads against a list of .com names would otherwise send
eight simultaneous queries to one Verisign host and get the caller's IP
rate-limited, after which every remaining answer is a refusal. The throttle is
per host, so a batch spanning many registries still runs genuinely in parallel.
MonoVM::Whois::Checker.whois("monovm.com")
# => {"monovm.com" => :registered}
MonoVM::Whois::Checker.whois(["monovm", "google.com"])
# => {"monovm.com" => :registered, "monovm.net" => :registered, ...}
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#concurrency ⇒ Object
readonly
Returns the value of attribute concurrency.
-
#popular_tlds ⇒ Object
readonly
Returns the value of attribute popular_tlds.
Class Method Summary collapse
-
.lookup(domains, options = {}) ⇒ Hash{String => Result}
As Checker.whois but each value is the full Result.
-
.whois(domains, options = {}) ⇒ Hash{String => Symbol}
Name => status.
Instance Method Summary collapse
- #check(domains) ⇒ Hash{String => Symbol}
- #check_detailed(domains) ⇒ Hash{String => Result}
-
#initialize(client: nil, config: nil, popular_tlds: nil, concurrency: nil) ⇒ Checker
constructor
A new instance of Checker.
Constructor Details
#initialize(client: nil, config: nil, popular_tlds: nil, concurrency: nil) ⇒ Checker
66 67 68 69 70 71 |
# File 'lib/monovm/whois/checker.rb', line 66 def initialize(client: nil, config: nil, popular_tlds: nil, concurrency: nil) @config = config || Configuration.new @client = client || Client.new(config: @config) @popular_tlds = normalise_tlds(popular_tlds || @config.popular_tlds) @concurrency = (concurrency || @config.concurrency).to_i.clamp(1, 64) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
64 65 66 |
# File 'lib/monovm/whois/checker.rb', line 64 def client @client end |
#concurrency ⇒ Object (readonly)
Returns the value of attribute concurrency.
64 65 66 |
# File 'lib/monovm/whois/checker.rb', line 64 def concurrency @concurrency end |
#popular_tlds ⇒ Object (readonly)
Returns the value of attribute popular_tlds.
64 65 66 |
# File 'lib/monovm/whois/checker.rb', line 64 def popular_tlds @popular_tlds end |
Class Method Details
.lookup(domains, options = {}) ⇒ Hash{String => Result}
39 40 41 |
# File 'lib/monovm/whois/checker.rb', line 39 def lookup(domains, = {}) new(**()).check_detailed(domains) end |
.whois(domains, options = {}) ⇒ Hash{String => Symbol}
32 33 34 |
# File 'lib/monovm/whois/checker.rb', line 32 def whois(domains, = {}) new(**()).check(domains) end |
Instance Method Details
#check(domains) ⇒ Hash{String => Symbol}
74 75 76 |
# File 'lib/monovm/whois/checker.rb', line 74 def check(domains) check_detailed(domains).transform_values(&:status) end |
#check_detailed(domains) ⇒ Hash{String => Result}
79 80 81 82 83 84 85 86 87 |
# File 'lib/monovm/whois/checker.rb', line 79 def check_detailed(domains) targets = (domains) return {} if targets.empty? results = run(targets) # Return in the order asked, which is what a caller rendering a table needs. targets.to_h { |name| [name.to_s, results[name.to_s]] } end |