Module: Ddig

Defined in:
lib/ddig.rb,
lib/ddig/ip.rb,
lib/ddig/cli.rb,
lib/ddig/ddr.rb,
lib/ddig/version.rb,
lib/ddig/nameserver.rb,
lib/ddig/resolver/dot.rb,
lib/ddig/resolver/do53.rb,
lib/ddig/ddr/verify_cert.rb,
lib/ddig/resolver/doh_h1.rb,
lib/ddig/resolver/dns_message.rb,
lib/ddig/ddr/designated_resolver.rb

Defined Under Namespace

Modules: Resolver Classes: Cli, Ddr, Error, Ip, Nameserver

Constant Summary collapse

VERSION =
"0.4.0"

Class Method Summary collapse

Class Method Details

.lookup(hostname, nameservers: nil, use_ipv4: nil, use_ipv6: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ddig.rb', line 14

def self.lookup(hostname, nameservers: nil, use_ipv4: nil, use_ipv6: nil)
  @hostname = hostname
  @nameservers = nameservers
  @use_ipv4 = use_ipv4
  @use_ipv6 = use_ipv6

  @nameserver = Ddig::Nameserver.new(nameservers: @nameservers)
  @ip = Ddig::Ip.new(use_ipv4: @use_ipv4, use_ipv6: @use_ipv6)

  @do53_ipv4 = Ddig::Resolver::Do53.new(hostname: @hostname, nameservers: @nameserver.servers, ip: :ipv4).lookup unless @ip.ip_type == :ipv6
  @do53_ipv6 = Ddig::Resolver::Do53.new(hostname: @hostname, nameservers: @nameserver.servers, ip: :ipv6).lookup unless @ip.ip_type == :ipv4

  @ddr = Ddig::Ddr.new(nameservers: @nameservers, ip: @ip.ip_type)
  @ddr.designated_resolvers.each do |designated_resolver|
    designated_resolver.lookup(@hostname)
  end

  {
    do53: {
      ipv4: @do53_ipv4,
      ipv6: @do53_ipv6,
    },
    ddr: @ddr.designated_resolvers
  }
end