Class: MonoVM::Whois::Configuration
- Inherits:
-
Object
- Object
- MonoVM::Whois::Configuration
- Defined in:
- lib/monovm/whois/configuration.rb
Overview
Every knob in one place, plus the defaults for the objects Client depends on.
Client takes its collaborators by injection, which is what makes it testable — but nobody wants to assemble a registry, a transport factory, an analyzer and a parser selector just to look up one domain. This class is the seam between those two needs: it holds the settings and builds sensible collaborators from them, while leaving every one of them replaceable.
MonoVM::Whois.configure do |config|
config.prefer = :whois
config.throttle_interval = 1.0
config.rules.insert_before("registry_marker", MyRule.new)
end
Constant Summary collapse
- DEFAULT_UNICODE_QUERY_TLDS =
TLDs whose registry wants an internationalised name in Unicode rather than Punycode, over port 43.
DENIC answers
Status: invalidforxn--mnchen-3ya.debut resolvesmünchen.decorrectly. Almost every other registry is the reverse — Verisign answers "No match" to a UTF-8 query, which reads as availability — so Punycode is the default and this is the short exception list. URLs are always ASCII, so it never applies to RDAP. [".de"].freeze
- DEFAULT_POPULAR_TLDS =
Tried in order when a name arrives without a TLD.
[".com", ".net", ".org", ".info"].freeze
Instance Attribute Summary collapse
- #analyzer ⇒ Object
-
#cache ⇒ Object
Middleware.
-
#cache_max_entries ⇒ Object
Middleware.
-
#cache_ttl ⇒ Object
Middleware.
-
#concurrency ⇒ Object
Behaviour.
-
#follow_referrals ⇒ Object
Behaviour.
-
#http_open_timeout ⇒ Object
Transport.
-
#http_read_timeout ⇒ Object
Transport.
-
#instrumentation ⇒ Object
Middleware.
-
#max_referrals ⇒ Object
Behaviour.
-
#override_path ⇒ Object
Behaviour.
- #parsers ⇒ Object
-
#popular_tlds ⇒ Object
Behaviour.
-
#prefer ⇒ Object
Behaviour.
-
#retry_attempts ⇒ Object
Middleware.
-
#retry_backoff ⇒ Object
Middleware.
- #rules ⇒ Object
- #server_registry ⇒ Object
-
#socket_connect_timeout ⇒ Object
Transport.
-
#socket_read_timeout ⇒ Object
Transport.
-
#throttle_interval ⇒ Object
Middleware.
- #transport_factory ⇒ Object
-
#unicode_query_tlds ⇒ Object
Behaviour.
-
#user_agent ⇒ Object
Transport.
-
#verify_ssl ⇒ Object
Transport.
Instance Method Summary collapse
-
#dup ⇒ Object
A copy, so a per-call override cannot mutate the global default.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#unicode_query?(tld) ⇒ Boolean
True when +tld+'s registry wants the Unicode form over port 43.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/monovm/whois/configuration.rb', line 58 def initialize @socket_connect_timeout = Transport::WhoisSocket::DEFAULT_CONNECT_TIMEOUT @socket_read_timeout = Transport::WhoisSocket::DEFAULT_READ_TIMEOUT @http_open_timeout = Transport::RdapHttp::DEFAULT_OPEN_TIMEOUT @http_read_timeout = Transport::RdapHttp::DEFAULT_READ_TIMEOUT @verify_ssl = true @user_agent = nil # RDAP first: a structured answer beats pattern-matching registry prose. @prefer = :rdap @follow_referrals = true @max_referrals = 1 @unicode_query_tlds = DEFAULT_UNICODE_QUERY_TLDS.dup @popular_tlds = DEFAULT_POPULAR_TLDS.dup @concurrency = 8 @override_path = Paths.override @cache = true @cache_ttl = Transport::Middleware::Cache::DEFAULT_TTL @cache_max_entries = Transport::Middleware::Cache::DEFAULT_MAX_ENTRIES @throttle_interval = Transport::Middleware::Throttle::DEFAULT_INTERVAL @retry_attempts = Transport::Middleware::Retry::DEFAULT_ATTEMPTS @retry_backoff = Transport::Middleware::Retry::DEFAULT_BACKOFF @instrumentation = nil end |
Instance Attribute Details
#analyzer ⇒ Object
92 93 94 |
# File 'lib/monovm/whois/configuration.rb', line 92 def analyzer @analyzer ||= Availability::Analyzer.new(rules: rules) end |
#cache ⇒ Object
Middleware
52 53 54 |
# File 'lib/monovm/whois/configuration.rb', line 52 def cache @cache end |
#cache_max_entries ⇒ Object
Middleware
52 53 54 |
# File 'lib/monovm/whois/configuration.rb', line 52 def cache_max_entries @cache_max_entries end |
#cache_ttl ⇒ Object
Middleware
52 53 54 |
# File 'lib/monovm/whois/configuration.rb', line 52 def cache_ttl @cache_ttl end |
#concurrency ⇒ Object
Behaviour
48 49 50 |
# File 'lib/monovm/whois/configuration.rb', line 48 def concurrency @concurrency end |
#follow_referrals ⇒ Object
Behaviour
48 49 50 |
# File 'lib/monovm/whois/configuration.rb', line 48 def follow_referrals @follow_referrals end |
#http_open_timeout ⇒ Object
Transport
44 45 46 |
# File 'lib/monovm/whois/configuration.rb', line 44 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Object
Transport
44 45 46 |
# File 'lib/monovm/whois/configuration.rb', line 44 def http_read_timeout @http_read_timeout end |
#instrumentation ⇒ Object
Middleware
52 53 54 |
# File 'lib/monovm/whois/configuration.rb', line 52 def instrumentation @instrumentation end |
#max_referrals ⇒ Object
Behaviour
48 49 50 |
# File 'lib/monovm/whois/configuration.rb', line 48 def max_referrals @max_referrals end |
#override_path ⇒ Object
Behaviour
48 49 50 |
# File 'lib/monovm/whois/configuration.rb', line 48 def override_path @override_path end |
#parsers ⇒ Object
96 97 98 |
# File 'lib/monovm/whois/configuration.rb', line 96 def parsers @parsers ||= Parser::Selector.default end |
#popular_tlds ⇒ Object
Behaviour
48 49 50 |
# File 'lib/monovm/whois/configuration.rb', line 48 def popular_tlds @popular_tlds end |
#prefer ⇒ Object
Behaviour
48 49 50 |
# File 'lib/monovm/whois/configuration.rb', line 48 def prefer @prefer end |
#retry_attempts ⇒ Object
Middleware
52 53 54 |
# File 'lib/monovm/whois/configuration.rb', line 52 def retry_attempts @retry_attempts end |
#retry_backoff ⇒ Object
Middleware
52 53 54 |
# File 'lib/monovm/whois/configuration.rb', line 52 def retry_backoff @retry_backoff end |
#rules ⇒ Object
88 89 90 |
# File 'lib/monovm/whois/configuration.rb', line 88 def rules @rules ||= Availability::RuleSet.default end |
#server_registry ⇒ Object
84 85 86 |
# File 'lib/monovm/whois/configuration.rb', line 84 def server_registry @server_registry ||= Registry::ServerRegistry.default(override_path: override_path) end |
#socket_connect_timeout ⇒ Object
Transport
44 45 46 |
# File 'lib/monovm/whois/configuration.rb', line 44 def socket_connect_timeout @socket_connect_timeout end |
#socket_read_timeout ⇒ Object
Transport
44 45 46 |
# File 'lib/monovm/whois/configuration.rb', line 44 def socket_read_timeout @socket_read_timeout end |
#throttle_interval ⇒ Object
Middleware
52 53 54 |
# File 'lib/monovm/whois/configuration.rb', line 52 def throttle_interval @throttle_interval end |
#transport_factory ⇒ Object
100 101 102 103 104 105 |
# File 'lib/monovm/whois/configuration.rb', line 100 def transport_factory @transport_factory ||= Transport::Factory.new( transports: default_transports, middleware: default_middleware ) end |
#unicode_query_tlds ⇒ Object
Behaviour
48 49 50 |
# File 'lib/monovm/whois/configuration.rb', line 48 def unicode_query_tlds @unicode_query_tlds end |
#user_agent ⇒ Object
Transport
44 45 46 |
# File 'lib/monovm/whois/configuration.rb', line 44 def user_agent @user_agent end |
#verify_ssl ⇒ Object
Transport
44 45 46 |
# File 'lib/monovm/whois/configuration.rb', line 44 def verify_ssl @verify_ssl end |
Instance Method Details
#dup ⇒ Object
A copy, so a per-call override cannot mutate the global default.
113 114 115 116 117 118 |
# File 'lib/monovm/whois/configuration.rb', line 113 def dup copy = super copy.unicode_query_tlds = unicode_query_tlds.dup copy.popular_tlds = popular_tlds.dup copy end |
#unicode_query?(tld) ⇒ Boolean
True when +tld+'s registry wants the Unicode form over port 43.
108 109 110 |
# File 'lib/monovm/whois/configuration.rb', line 108 def unicode_query?(tld) unicode_query_tlds.include?(tld) end |