Class: HTTPX::Resolver::HTTPS

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
ResolverMixin
Defined in:
lib/httpx/resolver/https.rb

Constant Summary collapse

NAMESERVER =
"https://1.1.1.1/dns-query"
RECORD_TYPES =
{
  "A" => Resolv::DNS::Resource::IN::A,
  "AAAA" => Resolv::DNS::Resource::IN::AAAA,
}.freeze
DEFAULTS =
{
  uri: NAMESERVER,
  use_get: false,
}.freeze

Constants included from ResolverMixin

ResolverMixin::CHECK_IF_IP

Constants included from Loggable

Loggable::COLORS

Instance Method Summary collapse

Methods included from ResolverMixin

#uncache

Methods included from Loggable

#log

Methods included from Callbacks

#emit, #on, #once

Constructor Details

#initialize(connection, options) ⇒ HTTPS

Returns a new instance of HTTPS.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/httpx/resolver/https.rb', line 28

def initialize(connection, options)
  @connection = connection
  @options = Options.new(options)
  @resolver_options = Resolver::Options.new(DEFAULTS.merge(@options.resolver_options || {}))
  @_record_types = Hash.new { |types, host| types[host] = RECORD_TYPES.keys.dup }
  @queries = {}
  @requests = {}
  @channels = []
  @uri = URI(@resolver_options.uri)
  @uri_addresses = nil
end

Instance Method Details

#<<(channel) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/httpx/resolver/https.rb', line 40

def <<(channel)
  @uri_addresses ||= Resolv.getaddresses(@uri.host)
  if @uri_addresses.empty?
    ex = ResolveError.new("Can't resolve #{channel.uri.host}")
    ex.set_backtrace(caller)
    emit(:error, channel, ex)
  else
    early_resolve(channel) || resolve(channel)
  end
end

#closed?Boolean

Returns:

  • (Boolean)


56
57
58
59
# File 'lib/httpx/resolver/https.rb', line 56

def closed?
  return true unless @resolver_channel
  resolver_channel.closed?
end

#timeoutObject



51
52
53
54
# File 'lib/httpx/resolver/https.rb', line 51

def timeout
  timeout = @options.timeout
  timeout.timeout
end