auth_dns_check 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a6b6f94144c7c9b89ef958e8bf0b500d20f983a48c9808f2efb7ec934e08bad7
4
+ data.tar.gz: cf39a080286c3e629c174ebc3acc7c9fb4a531cd2ad901a0e7941ab0c677f1c3
5
+ SHA512:
6
+ metadata.gz: e4be6a7c32fdc56b145520d38dde9661b6487dd570a88365b45761b2d98442a6a5757ffe35458ec609d5238d8940132ebba455f1854e8e05c4ac812786f59f0d
7
+ data.tar.gz: 512d91f2ae8ede5e1ceabdf62f0fc528e2a64467965ca15584d79f68e0d0fc1c81b2a628c7c0a7654c1b9959cb883540f83aef211f2b46051dcbb68ed1daa428
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 2.0.1
data/Dockerfile ADDED
@@ -0,0 +1,14 @@
1
+ FROM ruby:2.6
2
+
3
+ RUN gem install --no-doc bundler:2.0.1
4
+
5
+ WORKDIR /usr/src
6
+
7
+ COPY Gemfile .
8
+ COPY auth_dns_check.gemspec .
9
+ COPY lib/auth_dns_check/version.rb ./lib/auth_dns_check/version.rb
10
+ RUN bundle install --jobs=3 --retry=3
11
+ COPY lib ./lib
12
+ COPY spec ./spec
13
+
14
+ CMD bundle exec rspec -fd spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in auth_dns_check.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ auth_dns_check (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rake (13.0.1)
11
+ rspec (3.9.0)
12
+ rspec-core (~> 3.9.0)
13
+ rspec-expectations (~> 3.9.0)
14
+ rspec-mocks (~> 3.9.0)
15
+ rspec-core (3.9.2)
16
+ rspec-support (~> 3.9.3)
17
+ rspec-expectations (3.9.2)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.9.0)
20
+ rspec-mocks (3.9.1)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.9.0)
23
+ rspec-support (3.9.3)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ auth_dns_check!
30
+ bundler (< 3)
31
+ rake (~> 13.0)
32
+ rspec (~> 3.0)
33
+
34
+ BUNDLED WITH
35
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Sheldon Hearn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # AuthDnsCheck
2
+
3
+ Provides a client for checking that all authoritative DNS servers know
4
+ about a record and agree on its value(s).
5
+
6
+ Supports global or per-zone overrides for the set of authoritative DNS
7
+ servers, for bypassing AnyCast arrangements.
8
+
9
+ Does not yet support records other than A records.
10
+
11
+ Does not yet support IPv6.
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'auth_dns_check'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install auth_dns_check
28
+
29
+ ## Usage
30
+
31
+ Example:
32
+
33
+ ```
34
+ require "auth_dns_check"
35
+
36
+ client = AuthDnsCheck.client(
37
+ overrides: {
38
+ :default => [
39
+ Resolv::DNS.new(nameserver: "192.168.0.253"),
40
+ Resolv::DNS.new(nameserver: "192.168.0.252"),
41
+ ]
42
+ }
43
+ )
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")
50
+ ```
51
+
52
+ ## Development
53
+
54
+ 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.
55
+
56
+ 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).
57
+
58
+ ## Contributing
59
+
60
+ Bug reports and pull requests are welcome on GitHub at https://github.com/starjuice/auth_dns_check.
61
+
62
+ ## License
63
+
64
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,29 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "auth_dns_check/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "auth_dns_check"
8
+ spec.version = AuthDnsCheck::VERSION
9
+ spec.authors = ["Sheldon Hearn"]
10
+ spec.email = ["sheldonh@starjuice.net"]
11
+
12
+ spec.summary = %q{Authoritative DNS check}
13
+ spec.description = %q{Checks that all authoritatives answer for a new record.}
14
+ spec.homepage = "https://github.com/starjuice/auth_dns_check"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "< 3"
27
+ spec.add_development_dependency "rake", "~> 13.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "auth_dns_check"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,36 @@
1
+ version: '2.1'
2
+
3
+ services:
4
+ test:
5
+ build:
6
+ context: .
7
+ volumes:
8
+ - .:/usr/src
9
+ environment:
10
+ DEFAULT_RESOLVER: 10.0.0.251
11
+ networks:
12
+ auth_dns_check:
13
+ dns1:
14
+ image: resystit/bind9
15
+ volumes:
16
+ - ./docker/named.conf:/etc/bind/named.conf
17
+ - ./docker/dns1-internal.domain.db:/etc/bind/internal.domain.db
18
+ networks:
19
+ auth_dns_check:
20
+ ipv4_address: 10.0.0.251
21
+ dns2:
22
+ image: resystit/bind9
23
+ volumes:
24
+ - ./docker/named.conf:/etc/bind/named.conf
25
+ - ./docker/dns2-internal.domain.db:/etc/bind/internal.domain.db
26
+ networks:
27
+ auth_dns_check:
28
+ ipv4_address: 10.0.0.252
29
+ networks:
30
+ auth_dns_check:
31
+ driver: bridge
32
+ ipam:
33
+ driver: default
34
+ config:
35
+ - subnet: 10.0.0.0/24
36
+
@@ -0,0 +1,22 @@
1
+ $ORIGIN internal.domain.
2
+ $TTL 86400
3
+ @ SOA dns1.internal.domain. hostmaster.internal.domain. (
4
+ 2001062501 ; serial
5
+ 21600 ; refresh after 6 hours
6
+ 3600 ; retry after 1 hour
7
+ 604800 ; expire after 1 week
8
+ 86400 ) ; minimum TTL of 1 day
9
+ ;
10
+ NS dns1
11
+ NS dns2
12
+ dns1 IN A 10.0.0.251
13
+ dns2 IN A 10.0.0.252
14
+ ;
15
+ same IN A 127.0.0.1
16
+ different IN A 127.0.0.1
17
+ ;
18
+ multi-same IN A 127.0.0.1
19
+ multi-same IN A 127.0.0.3
20
+ ;
21
+ multi-different IN A 127.0.0.1
22
+ multi-different IN A 127.0.0.3
@@ -0,0 +1,22 @@
1
+ $ORIGIN internal.domain.
2
+ $TTL 86400
3
+ @ SOA dns1.internal.domain. hostmaster.internal.domain. (
4
+ 2001062501 ; serial
5
+ 21600 ; refresh after 6 hours
6
+ 3600 ; retry after 1 hour
7
+ 604800 ; expire after 1 week
8
+ 86400 ) ; minimum TTL of 1 day
9
+ ;
10
+ NS dns1
11
+ NS dns2
12
+ dns1 IN A 10.0.0.251
13
+ dns2 IN A 10.0.0.252
14
+ ;
15
+ same IN A 127.0.0.1
16
+ different IN A 127.0.0.2
17
+ ;
18
+ multi-same IN A 127.0.0.3
19
+ multi-same IN A 127.0.0.1
20
+ ;
21
+ multi-different IN A 127.0.0.3
22
+ multi-different IN A 127.0.0.2
data/docker/named.conf ADDED
@@ -0,0 +1,21 @@
1
+ options {
2
+ directory "/var/bind";
3
+
4
+ // Configure the IPs to listen on here.
5
+ listen-on port 53 { any; };
6
+ listen-on-v6 { none; };
7
+ allow-transfer {
8
+ none;
9
+ };
10
+ pid-file "/var/run/named/named.pid";
11
+ allow-recursion { none; };
12
+ recursion no;
13
+
14
+ querylog yes;
15
+ };
16
+
17
+ zone "internal.domain" IN {
18
+ type master;
19
+ file "/etc/bind/internal.domain.db";
20
+ notify no;
21
+ };
@@ -0,0 +1,13 @@
1
+ require "resolv"
2
+
3
+ require "auth_dns_check/client"
4
+ require "auth_dns_check/version"
5
+
6
+ module AuthDnsCheck
7
+ class Error < StandardError; end
8
+
9
+ def self.client(overrides: {}, default: Resolv::DNS.new)
10
+ Client.new(overrides: overrides, default: default)
11
+ end
12
+
13
+ end
@@ -0,0 +1,42 @@
1
+ module AuthDnsCheck
2
+
3
+ class Client
4
+
5
+ def initialize(overrides: {}, default: Resolv::DNS.new)
6
+ @overrides = overrides
7
+ @default = default
8
+ end
9
+
10
+ def all?(fqdn)
11
+ answers = authoritatives_for(fqdn).
12
+ map { |x| x.getaddresses(fqdn) }.
13
+ map { |x| x.collect(&:to_s).sort }
14
+ answers.all? { |x| x.any? and x == answers.first }
15
+ end
16
+
17
+ private
18
+
19
+ def authoritatives_for(fqdn)
20
+ zone = fqdn.gsub(/\A[^.]+\./, '')
21
+ overridden_authoritatives_for(zone) || overridden_authoritatives_for(:default) || default_authoritatives_for(zone)
22
+ end
23
+
24
+ def overridden_authoritatives_for(zone)
25
+ @overrides[zone]
26
+ end
27
+
28
+ def default_authoritatives_for(zone)
29
+ @default.
30
+ getresources(zone, Resolv::DNS::Resource::IN::NS).
31
+ map(&:name).
32
+ map(&:to_s).
33
+ map { |x| @default.getaddresses(x) }.
34
+ flatten.
35
+ map(&:to_s).
36
+ uniq.
37
+ map { |x| Resolv::DNS.new(nameserver: x) }
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,3 @@
1
+ module AuthDnsCheck
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: auth_dns_check
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sheldon Hearn
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-05-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "<"
18
+ - !ruby/object:Gem::Version
19
+ version: '3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "<"
25
+ - !ruby/object:Gem::Version
26
+ version: '3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Checks that all authoritatives answer for a new record.
56
+ email:
57
+ - sheldonh@starjuice.net
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Dockerfile
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - auth_dns_check.gemspec
72
+ - bin/console
73
+ - bin/setup
74
+ - docker-compose.yml
75
+ - docker/dns1-internal.domain.db
76
+ - docker/dns2-internal.domain.db
77
+ - docker/named.conf
78
+ - lib/auth_dns_check.rb
79
+ - lib/auth_dns_check/client.rb
80
+ - lib/auth_dns_check/version.rb
81
+ homepage: https://github.com/starjuice/auth_dns_check
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.7.6
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Authoritative DNS check
105
+ test_files: []