auth_dns_check 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6b6f94144c7c9b89ef958e8bf0b500d20f983a48c9808f2efb7ec934e08bad7
4
- data.tar.gz: cf39a080286c3e629c174ebc3acc7c9fb4a531cd2ad901a0e7941ab0c677f1c3
3
+ metadata.gz: 2ce2d9f93dd5a2d8201b420bd5b7bf570dc019a8aa55206263787871d1c60052
4
+ data.tar.gz: 0cc5585ba4a40af75e6eed17cb8188195616d7d4b500f7da4b566f3a8f008f3c
5
5
  SHA512:
6
- metadata.gz: e4be6a7c32fdc56b145520d38dde9661b6487dd570a88365b45761b2d98442a6a5757ffe35458ec609d5238d8940132ebba455f1854e8e05c4ac812786f59f0d
7
- data.tar.gz: 512d91f2ae8ede5e1ceabdf62f0fc528e2a64467965ca15584d79f68e0d0fc1c81b2a628c7c0a7654c1b9959cb883540f83aef211f2b46051dcbb68ed1daa428
6
+ metadata.gz: bfa7db53ed72044c4d8c3a09315875b9496836ca35eac53ebcda6e43d631b0b1322d3f82b1d9a61b59b6c0db528d7103e07885c842504d18b3e48d245b181cdc
7
+ data.tar.gz: da427b2d7d45597983596664749a0a42fafcd92a73fac24d668c366578c3c444bc9eb480d4180e30e8c654b5d970d013480be6e31b4cc234efb2702e76ea4f0b
data/README.md CHANGED
@@ -33,6 +33,17 @@ Example:
33
33
  ```
34
34
  require "auth_dns_check"
35
35
 
36
+ # Check that the authoritative name servers for peculiardomain.com
37
+ # agree that changed.peculiardomain.com has the address 192.168.1.1
38
+ # and no other addresses.
39
+ #
40
+ client = AuthDnsCheck.client
41
+ client.has_ip?("changed.peculiardomain.com", "192.168.1.1")
42
+
43
+ # Ignore the NS records for peculiardomain.com and check that
44
+ # 192.168.0.253 and 192.168.0.252 both know about and agree on
45
+ # any and all records for newhost.peculiardomain.com.
46
+ #
36
47
  client = AuthDnsCheck.client(
37
48
  overrides: {
38
49
  :default => [
@@ -41,12 +52,7 @@ client = AuthDnsCheck.client(
41
52
  ]
42
53
  }
43
54
  )
44
-
45
- # Ignore the NS records for peculiardomain.com and check that
46
- # 192.168.0.253 and 192.168.0.252 both know about and agree on
47
- # 4acf8ea915b7.peculiardomain.com.
48
- #
49
- client.all?("4acf8ea915b7.example.com")
55
+ client.all?("newhost.peculiardomain.com")
50
56
  ```
51
57
 
52
58
  ## Development
data/docker-compose.yml CHANGED
@@ -10,6 +10,9 @@ services:
10
10
  DEFAULT_RESOLVER: 10.0.0.251
11
11
  networks:
12
12
  auth_dns_check:
13
+ depends_on:
14
+ - dns1
15
+ - dns2
13
16
  dns1:
14
17
  image: resystit/bind9
15
18
  volumes:
@@ -8,14 +8,31 @@ module AuthDnsCheck
8
8
  end
9
9
 
10
10
  def all?(fqdn)
11
- answers = authoritatives_for(fqdn).
12
- map { |x| x.getaddresses(fqdn) }.
13
- map { |x| x.collect(&:to_s).sort }
11
+ answers = get_addresses(fqdn)
14
12
  answers.all? { |x| x.any? and x == answers.first }
15
13
  end
16
14
 
15
+ def has_ip?(fqdn, ip)
16
+ answers = get_addresses(fqdn)
17
+ answers.all? do |x|
18
+ x.any? and x.all? { |i| i == ip }
19
+ end
20
+ end
21
+
17
22
  private
18
23
 
24
+ def get_addresses(fqdn)
25
+ get_authoritatives(fqdn).
26
+ map { |x| x.getaddresses(fqdn) }.
27
+ map { |x| x.collect(&:to_s).sort }
28
+ end
29
+
30
+ def get_authoritatives(fqdn)
31
+ authoritatives_for(fqdn).tap do |auths|
32
+ auths.any? or raise(Error, "no name servers found for #{fqdn}")
33
+ end
34
+ end
35
+
19
36
  def authoritatives_for(fqdn)
20
37
  zone = fqdn.gsub(/\A[^.]+\./, '')
21
38
  overridden_authoritatives_for(zone) || overridden_authoritatives_for(:default) || default_authoritatives_for(zone)
@@ -1,3 +1,3 @@
1
1
  module AuthDnsCheck
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth_dns_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon Hearn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-08 00:00:00.000000000 Z
11
+ date: 2020-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler