Module: MonoVM::Whois
- Defined in:
- lib/monovm/whois.rb,
lib/monovm/whois/cli.rb,
lib/monovm/whois/paths.rb,
lib/monovm/whois/client.rb,
lib/monovm/whois/errors.rb,
lib/monovm/whois/result.rb,
lib/monovm/whois/checker.rb,
lib/monovm/whois/version.rb,
lib/monovm/whois/endpoint.rb,
lib/monovm/whois/punycode.rb,
lib/monovm/whois/response.rb,
lib/monovm/whois/domain_name.rb,
lib/monovm/whois/parser/base.rb,
lib/monovm/whois/configuration.rb,
lib/monovm/whois/parser/record.rb,
lib/monovm/whois/whois_handler.rb,
lib/monovm/whois/transport/base.rb,
lib/monovm/whois/parser/selector.rb,
lib/monovm/whois/parser/icann_rdd.rb,
lib/monovm/whois/parser/key_value.rb,
lib/monovm/whois/parser/rdap_json.rb,
lib/monovm/whois/availability/rule.rb,
lib/monovm/whois/referral/follower.rb,
lib/monovm/whois/transport/factory.rb,
lib/monovm/whois/registry/definition.rb,
lib/monovm/whois/registry/resolution.rb,
lib/monovm/whois/transport/rdap_http.rb,
lib/monovm/whois/availability/context.rb,
lib/monovm/whois/availability/verdict.rb,
lib/monovm/whois/availability/analyzer.rb,
lib/monovm/whois/availability/patterns.rb,
lib/monovm/whois/availability/rule_set.rb,
lib/monovm/whois/registry/sources/base.rb,
lib/monovm/whois/transport/whois_socket.rb,
lib/monovm/whois/registry/server_registry.rb,
lib/monovm/whois/transport/middleware/base.rb,
lib/monovm/whois/registry/sources/json_file.rb,
lib/monovm/whois/transport/middleware/cache.rb,
lib/monovm/whois/transport/middleware/retry.rb,
lib/monovm/whois/availability/rules/no_match.rb,
lib/monovm/whois/availability/rules/recordless.rb,
lib/monovm/whois/transport/middleware/throttle.rb,
lib/monovm/whois/availability/rules/rdap_object.rb,
lib/monovm/whois/availability/rules/premium_name.rb,
lib/monovm/whois/availability/rules/status_field.rb,
lib/monovm/whois/availability/rules/tld_specific.rb,
lib/monovm/whois/registry/sources/iana_bootstrap.rb,
lib/monovm/whois/availability/rules/server_refusal.rb,
lib/monovm/whois/availability/rules/wrong_registry.rb,
lib/monovm/whois/availability/rules/registry_marker.rb,
lib/monovm/whois/transport/middleware/instrumentation.rb,
lib/monovm/whois/availability/rules/registration_fields.rb,
lib/monovm/whois/availability/rules/availability_keywords.rb,
lib/monovm/whois/availability/rules/explicit_unavailability.rb
Overview
Domain WHOIS and RDAP lookups.
The short way in:
MonoVM::Whois.available?("monovm.com") # => false
MonoVM::Whois.lookup("monovm.com") # => #<Result "monovm.com" registered>
MonoVM::Whois.whois(["monovm", "bing.com"])
Settings are global unless overridden per call:
MonoVM::Whois.configure do |config|
config.prefer = :whois # port 43 before RDAP
config.throttle_interval = 1.0 # be gentler with registries
config.instrumentation = ->(event) { Rails.logger.info(event) }
end
Defined Under Namespace
Modules: Availability, Parser, Paths, Punycode, Referral, Registry, Transport Classes: CLI, Checker, Client, Configuration, ConnectionError, DefinitionsError, DomainName, EmptyResponseError, Endpoint, Error, InvalidDomainError, Response, Result, ServerRefusedError, TimeoutError, UnsupportedTldError, WhoisHandler
Constant Summary collapse
- VERSION =
"1.0.0"
Class Method Summary collapse
-
.available?(domain) ⇒ Boolean
True only when availability was positively established.
-
.check(domains, options = {}) ⇒ Hash{String => Result}
Full results rather than statuses.
-
.client ⇒ Object
The shared client.
-
.config ⇒ Object
The global configuration.
-
.configure {|config| ... } ⇒ Object
Yields Whois.config for editing, then discards the cached client so the next lookup picks the changes up.
-
.explain(domain) ⇒ Hash
Why a lookup came out the way it did, including every rule consulted.
-
.handler(domain, **options) ⇒ WhoisHandler
A single-domain handler object, camelCase aliases included.
-
.lookup(domain) ⇒ Result
Look one domain up.
-
.registered?(domain) ⇒ Boolean
True when the name is registered.
-
.reset! ⇒ Object
Throw away the global configuration and client.
-
.supported_tlds ⇒ Array<String>
Every TLD that can be looked up, dotted and sorted.
- .supports?(tld) ⇒ Boolean
-
.whois(domains, options = {}) ⇒ Hash{String => Symbol}
Check one or many domains, expanding a bare name across popular TLDs.
Class Method Details
.available?(domain) ⇒ Boolean
Returns true only when availability was positively established. A refusal, a timeout or an unreadable response is false, not true.
78 79 80 |
# File 'lib/monovm/whois.rb', line 78 def available?(domain) client.available?(domain) end |
.check(domains, options = {}) ⇒ Hash{String => Result}
Full results rather than statuses.
101 102 103 104 105 |
# File 'lib/monovm/whois.rb', line 101 def check(domains, = {}) return Checker.new(client: client, config: config).check_detailed(domains) if .empty? Checker.lookup(domains, ) end |
.client ⇒ Object
The shared client. Built once, because it owns the definition tables and the caches and throttle clocks that make repeated lookups cheap and polite.
64 65 66 |
# File 'lib/monovm/whois.rb', line 64 def client @client || mutex.synchronize { @client ||= Client.new(config: config) } end |
.config ⇒ Object
The global configuration. Mutating it affects the shared client.
41 42 43 |
# File 'lib/monovm/whois.rb', line 41 def config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
Yields config for editing, then discards the cached client so the next lookup picks the changes up.
49 50 51 52 53 |
# File 'lib/monovm/whois.rb', line 49 def configure yield config if block_given? reset_client! config end |
.explain(domain) ⇒ Hash
Why a lookup came out the way it did, including every rule consulted.
117 118 119 |
# File 'lib/monovm/whois.rb', line 117 def explain(domain) client.explain(domain) end |
.handler(domain, **options) ⇒ WhoisHandler
A single-domain handler object, camelCase aliases included.
110 111 112 |
# File 'lib/monovm/whois.rb', line 110 def handler(domain, **) WhoisHandler.whois(domain, **) end |
.lookup(domain) ⇒ Result
Look one domain up.
72 73 74 |
# File 'lib/monovm/whois.rb', line 72 def lookup(domain) client.lookup(domain) end |
.registered?(domain) ⇒ Boolean
Returns true when the name is registered.
83 84 85 |
# File 'lib/monovm/whois.rb', line 83 def registered?(domain) lookup(domain).registered? end |
.reset! ⇒ Object
Throw away the global configuration and client. Mainly for tests.
56 57 58 59 60 |
# File 'lib/monovm/whois.rb', line 56 def reset! @config = nil reset_client! self end |
.supported_tlds ⇒ Array<String>
Returns every TLD that can be looked up, dotted and sorted.
122 123 124 |
# File 'lib/monovm/whois.rb', line 122 def supported_tlds config.server_registry.supported_tlds end |
.supports?(tld) ⇒ Boolean
127 128 129 |
# File 'lib/monovm/whois.rb', line 127 def supports?(tld) config.server_registry.supports?(tld) end |
.whois(domains, options = {}) ⇒ Hash{String => Symbol}
Check one or many domains, expanding a bare name across popular TLDs.
92 93 94 95 96 |
# File 'lib/monovm/whois.rb', line 92 def whois(domains, = {}) return Checker.new(client: client, config: config).check(domains) if .empty? Checker.whois(domains, ) end |