Class: AuthDnsCheck::Client
- Inherits:
-
Object
- Object
- AuthDnsCheck::Client
- Defined in:
- lib/auth_dns_check/client.rb
Overview
TODO:
IPv6 not supported
Client for performing authoritative DNS checks
Constant Summary collapse
- DEFAULT_TYPES =
Default record types for checks like
all?
["A"]
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
default resolver for finding authoritative name servers.
-
#overrides ⇒ Object
readonly
authoritative name server overrides.
Instance Method Summary collapse
-
#all?(fqdn, types: DEFAULT_TYPES) ⇒ Boolean
Check authoritative agreement for a name.
-
#has_ip?(fqdn, ip) ⇒ Boolean
Check authoritative agreement for the specific address for a name.
-
#initialize(overrides: {}, default: Resolv::DNS.new("/etc/resolv.conf")) ⇒ Client
constructor
Initialize a new Client.
Constructor Details
#initialize(overrides: {}, default: Resolv::DNS.new("/etc/resolv.conf")) ⇒ Client
Initialize a new Client
24 25 26 27 |
# File 'lib/auth_dns_check/client.rb', line 24 def initialize(overrides: {}, default: Resolv::DNS.new("/etc/resolv.conf")) @overrides = overrides @default = default end |
Instance Attribute Details
#default ⇒ Object (readonly)
default resolver for finding authoritative name servers
15 16 17 |
# File 'lib/auth_dns_check/client.rb', line 15 def default @default end |
#overrides ⇒ Object (readonly)
authoritative name server overrides
12 13 14 |
# File 'lib/auth_dns_check/client.rb', line 12 def overrides @overrides end |
Instance Method Details
#all?(fqdn, types: DEFAULT_TYPES) ⇒ Boolean
TODO:
Records of types other than A not yet supported
Check authoritative agreement for a name
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/auth_dns_check/client.rb', line 35 def all?(fqdn, types: DEFAULT_TYPES) non_empty_set = false types.all? { |type| resources = get_resources(fqdn, type: type) resources.all? do |x| non_empty_set = true unless x.empty? x == resources.first end } && non_empty_set end |
#has_ip?(fqdn, ip) ⇒ Boolean
Check authoritative agreement for the specific address for a name
52 53 54 55 56 57 |
# File 'lib/auth_dns_check/client.rb', line 52 def has_ip?(fqdn, ip) answers = get_addresses(fqdn) answers.all? do |x| x.any? and x.all? { |i| i == ip } end end |