auth_dns_check 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22c37a6683b09a94fca8de172138b353213f34db8ef4cff9ca5dc0c0235e13bc
4
- data.tar.gz: b90bc601c6fc5683829e0dd11353410b1a7ad97fef481dee7bc75e67f1aee43e
3
+ metadata.gz: 694aa2030b2a1849a624a23471174281a7e9ad75489c985124d7cb987c640ec7
4
+ data.tar.gz: 3df4dd5171e5979c261ed0b227797dd8ffa4b5a8909a4254f1fd9195dc82ef36
5
5
  SHA512:
6
- metadata.gz: 82db5eb1fe0e5e9b0a4a85ade3327823ea0ab1e6c976081652f7795e08a88c13fdd72cde8094426fa7c805716fda193c49ac0d441ae7e701c0a972218ad4983e
7
- data.tar.gz: 9c6d450d60076a196fa3867e027ba96c3ec5383cc74bf2c6e14bcf145e47ca057a7e7abf05484be3625c1f7bc7d25a2ed0198187de7cca0e31991369cd105375
6
+ metadata.gz: 3a6f8f88f72d3c6afc4f6d5dafe228ed91001f4e8880bb2a5f9520e2c90b33c3dd87b340cbeccfc21dc243405b3cf54d5544df0bf2258a090dbb1381697b9c1f
7
+ data.tar.gz: c5cbd271edf11b44f33d2a4f32a8f363c7872f8b0052f3aa8d9f37c697d1097659aeea58c2c941483b682aa14487932060dae1eb8fae63d550c557fe283326b2
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem](https://img.shields.io/gem/v/auth_dns_check.svg?style=flat)](https://rubygems.org/gems/auth_dns_check "View this project in Rubygems")
2
+
1
3
  # AuthDnsCheck
2
4
 
3
5
  Provides a client for checking that all authoritative DNS servers know
@@ -26,6 +28,10 @@ Or install it yourself as:
26
28
 
27
29
  $ gem install auth_dns_check
28
30
 
31
+ ## Documentation
32
+
33
+ Full API documentation is available on [rubydoc.info](https://www.rubydoc.info/gems/auth_dns_check).
34
+
29
35
  ## Usage
30
36
 
31
37
  Example:
@@ -37,14 +43,14 @@ require "auth_dns_check"
37
43
  # agree that changed.peculiardomain.com has the address 192.168.1.1
38
44
  # and no other addresses.
39
45
  #
40
- client = AuthDnsCheck.client
46
+ client = AuthDnsCheck::Client.new
41
47
  client.has_ip?("changed.peculiardomain.com", "192.168.1.1")
42
48
 
43
49
  # Ignore the NS records for peculiardomain.com and check that
44
50
  # 192.168.0.253 and 192.168.0.252 both know about and agree on
45
51
  # any and all records for newhost.peculiardomain.com.
46
52
  #
47
- client = AuthDnsCheck.client(
53
+ client = AuthDnsCheck::Client.new(
48
54
  overrides: {
49
55
  :default => [
50
56
  Resolv::DNS.new(nameserver: "192.168.0.253"),
@@ -57,7 +63,17 @@ client.all?("newhost.peculiardomain.com")
57
63
 
58
64
  ## Development
59
65
 
60
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
66
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
67
+
68
+ Note that `rake spec` does not work. The tests rely on a pair of name servers configured with fixtures.
69
+
70
+ To run the tests:
71
+
72
+ ```
73
+ docker-compose down --volumes --remove-orphans && \
74
+ docker-compose build test && \
75
+ docker-compose run test
76
+ ```
61
77
 
62
78
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
63
79
 
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "bundler", "< 3"
27
27
  spec.add_development_dependency "rake", "~> 13.0"
28
28
  spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "yard", "~> 0.9"
29
30
  end
@@ -3,10 +3,19 @@ require "resolv"
3
3
  require "auth_dns_check/client"
4
4
  require "auth_dns_check/version"
5
5
 
6
+ # Parent module for the authoritative DNS check library
7
+ #
8
+ # @see Client
6
9
  module AuthDnsCheck
10
+ # Any AuthDnsCheck error
11
+ #
12
+ # Currently the only error is a failure to find authoritative name servers on the network.
7
13
  class Error < StandardError; end
8
14
 
9
- def self.client(overrides: {}, default: Resolv::DNS.new)
15
+ # Returns a new {Client}
16
+ #
17
+ # @deprecated See {Client}
18
+ def self.client(overrides: {}, default: Resolv::DNS.new("/etc/resolv.conf"))
10
19
  Client.new(overrides: overrides, default: default)
11
20
  end
12
21
 
@@ -1,17 +1,45 @@
1
1
  module AuthDnsCheck
2
2
 
3
+ # Client for performing authoritative DNS checks
4
+ #
5
+ # @todo IPv6 not supported
3
6
  class Client
4
7
 
5
- def initialize(overrides: {}, default: Resolv::DNS.new)
8
+ # authoritative name server overrides
9
+ attr_reader :overrides
10
+
11
+ # default resolver for finding authoritative name servers
12
+ attr_reader :default
13
+
14
+ # Initialize a new Client
15
+ #
16
+ # @param overrides [Hash<String,Array<Resolv::DNS>>] authoritative name server overrides.
17
+ # Maps domain names to lists of name servers that should override those published for the domain.
18
+ # The special domain name {Symbol} +:default+ may list the name servers that should override any other domain.
19
+ # @param default [Resolv::DNS] default resolver for finding authoritative name servers.
20
+ # Note that this is not the same as +overrides[:default]+.
21
+ def initialize(overrides: {}, default: Resolv::DNS.new("/etc/resolv.conf"))
6
22
  @overrides = overrides
7
23
  @default = default
8
24
  end
9
25
 
26
+ # Check authoritative agreement for a name
27
+ #
28
+ # @param fqdn [String] the name to check
29
+ # @return [Boolean] whether all authoritative agree that +fqdn+ has the same non-empty set of records
30
+ # @raise [Error] if authoritative name servers could not be found
31
+ # @todo Records of types other than A not yet supported
10
32
  def all?(fqdn)
11
33
  answers = get_addresses(fqdn)
12
34
  answers.all? { |x| x.any? and x == answers.first }
13
35
  end
14
36
 
37
+ # Check authoritative agreement for the specific address for a name
38
+ #
39
+ # @param fqdn [String] the name to check
40
+ # @param ip [String] the expected address
41
+ # @return [Boolean] whether all authoritative name servers agree that the only address of +name+ is +ip+
42
+ # @raise [Error] if authoritative name servers could not be found
15
43
  def has_ip?(fqdn, ip)
16
44
  answers = get_addresses(fqdn)
17
45
  answers.all? do |x|
@@ -1,3 +1,4 @@
1
1
  module AuthDnsCheck
2
- VERSION = "0.3.0"
2
+ # The version of the auth_dns_check gem
3
+ VERSION = "0.3.1"
3
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth_dns_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon Hearn
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.9'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.9'
55
69
  description: Checks that all authoritatives answer for a new record.
56
70
  email:
57
71
  - sheldonh@starjuice.net