record_store 6.0.1 → 6.1.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: 9c526e771b65c9da7f83836311bfc8c7b2af502a6801256ccdaa540b54df4138
4
- data.tar.gz: f5e34d123f4dbef6d2206c4703310af91784deb0d0d2681de05f4aea78b83985
3
+ metadata.gz: d6686f890657b7a250384d189c2c377519616711a8295f510bbb140abaefde22
4
+ data.tar.gz: 00066a49bd826aded557ba3c0a6cb60216ce53feb0c33efd89de9ae7792a5d7c
5
5
  SHA512:
6
- metadata.gz: d5c507ba11cdefb048f6ceb74f30c1edef6a0f4bd0f0558126f7be02de3b9b38bab5c9d02bf8c8fec9f07ac59207dd24115fac7d0819141029f2691da989ada2
7
- data.tar.gz: d688116ba3470d5ff1a4ab4d74b8d38d8d274d1180988839679d1d9b8aeb2e813a20b3fbc0634077e9a216b74d28ca1b0e3da125c43240488f5626a9c6fbd265
6
+ metadata.gz: 642f48f0c639da2f9c3f5cb16bc3265504c647797586bbc6d7aa06f3667dbfaefe8977a4744f8a390ffd7bb45b2567e0964e8e719793182bbca05ccb9143d1e2
7
+ data.tar.gz: 34e8d630d6b53dc22370f1472cd292b218e79136772151c403b46cc4eb027aa9377beebd17524dac6b37d47645ed7597a756f40f78511ebf0f5678ea9a61c74d
@@ -1,6 +1,13 @@
1
1
  # CHANGELOG
2
+
3
+ ## 6.1.0
4
+ - sort zone files [FEATURE]
5
+ - CLI support for specifying zones for validate_authority [FEATURE]
6
+ - retry failed lookup using another nameserver if unreachable [BUGFIX]
7
+ - ignore records other than NS in authority section [BUGFIX]
8
+
2
9
  ## 6.0.1
3
- - add API rate limiting to DNSimple provider
10
+ - add API rate limiting to DNSimple provider [FEATURE]
4
11
 
5
12
  ## 6.0.0
6
13
  - add `--all` option for `record-store diff` to compare ignored records too [FEATURE]
@@ -220,12 +220,14 @@ module RecordStore
220
220
  end
221
221
  end
222
222
 
223
- desc 'validate_authority', 'Validates that authoritative nameservers match the providers'
223
+ desc 'validate_authority [ZONE ...]', 'Validates that authoritative nameservers match the providers'
224
224
  option :verbose, desc: 'Include valid zones in output', aliases: '-v', type: :boolean, default: false
225
- def validate_authority
225
+ def validate_authority(*zones)
226
226
  verbose = options.fetch('verbose')
227
227
 
228
228
  Zone.each do |name, zone|
229
+ next unless zones.empty? || zones.include?(name)
230
+
229
231
  authority = zone.fetch_authority
230
232
 
231
233
  delegation = Hash.new { |h, k| h[k] = [] }
@@ -1,3 +1,3 @@
1
1
  module RecordStore
2
- VERSION = '6.0.1'.freeze
2
+ VERSION = '6.1.0'.freeze
3
3
  end
@@ -129,14 +129,12 @@ module RecordStore
129
129
  )
130
130
 
131
131
  def fetch_authority(nameserver = ROOT_SERVERS.sample)
132
- authority = Resolv::DNS.open(nameserver: nameserver) do |resolv|
133
- resolv.fetch_resource(name, Resolv::DNS::Resource::IN::SOA) do |reply, name|
134
- break if reply.answer.any?
132
+ authority = fetch_soa(nameserver) do |reply, _name|
133
+ break if reply.answer.any?
135
134
 
136
- raise "No authority found (#{name})" unless reply.authority.any?
135
+ raise "No authority found (#{name})" unless reply.authority.any?
137
136
 
138
- break extract_authority(reply)
139
- end
137
+ break extract_authority(reply.authority)
140
138
  end
141
139
 
142
140
  # candidate DNS name is returned instead when NXDomain or other error
@@ -147,18 +145,39 @@ module RecordStore
147
145
 
148
146
  private
149
147
 
150
- def extract_authority(reply)
151
- authority = reply.authority.sample
148
+ def fetch_soa(nameserver)
149
+ Resolv::DNS.open(nameserver: nameserver) do |resolv|
150
+ resolv.fetch_resource(name, Resolv::DNS::Resource::IN::SOA) do |reply, name|
151
+ yield reply, name
152
+ end
153
+ end
154
+ end
152
155
 
153
- if unrooted_name.casecmp?(authority.first.to_s)
154
- build_authority(reply.authority)
156
+ def resolve_authority(authority)
157
+ nameservers = authority.map { |a| a.last.name.to_s }
158
+
159
+ begin
160
+ nameserver = nameservers.shift
161
+ fetch_authority(nameserver)
162
+ rescue Errno::EHOSTUNREACH => e
163
+ $stderr.puts "Warning: #{e} [host=#{nameserver}]"
164
+ raise if nameservers.empty?
165
+ retry
166
+ end
167
+ end
168
+
169
+ def extract_authority(authority)
170
+ if unrooted_name.casecmp?(authority.first.first.to_s)
171
+ build_authority(authority)
155
172
  else
156
- fetch_authority(authority.last.name.to_s) || build_authority(reply.authority)
173
+ resolve_authority(authority) || build_authority(authority)
157
174
  end
158
175
  end
159
176
 
160
177
  def build_authority(authority)
161
- authority.map.with_index do |(name, ttl, data), index|
178
+ ns = authority.select { |_name, _ttl, data| data.is_a?(Resolv::DNS::Resource::IN::NS) }
179
+
180
+ ns.map.with_index do |(name, ttl, data), index|
162
181
  Record::NS.new(ttl: ttl, fqdn: name.to_s, nsdname: data.name.to_s, record_id: index)
163
182
  end
164
183
  end
@@ -10,6 +10,7 @@ module RecordStore
10
10
  def defined
11
11
  @defined ||= yaml_files
12
12
  .map { |file| load_yml_zone_definition(file) }
13
+ .sort_by(&:unrooted_name)
13
14
  .index_by(&:unrooted_name)
14
15
  end
15
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: record_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.1
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-05-13 00:00:00.000000000 Z
12
+ date: 2020-05-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor