dns-zonefile 1.1.2 → 1.1.3

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
  SHA1:
3
- metadata.gz: dd38c55e83f1bf952fdba0831fd183b81bf2f556
4
- data.tar.gz: 11c7b7481eb3bf6f56ca8fe46f64ee4c5516e421
3
+ metadata.gz: 2d2cf8f81008cd088e5a4beb910bdd6fac23bc21
4
+ data.tar.gz: 9585b78227f0ec5b9fe993c108febfc20962c9fe
5
5
  SHA512:
6
- metadata.gz: 3820bd3385d77de0f50d99afa3ab5bd74ca370ebfb92caa9984042d318936c9e9de968437af0d117f97d65341b6455594c1262417011a39d9be6696ecb339ee7
7
- data.tar.gz: 83b879336f94c811c1b4075b7a5e86dedc2304ae94f7d6dad28c2b09166c665d565be90c3f4f37dae2fc74ea7a45dda001a07318b3785fc48f977db58f407918
6
+ metadata.gz: d361f79d9ea5ff9f0ff49ce4bb21d3c31e2e4794169c752edd78e51f3d0d90641b8bd6eea1d79f1c248ed5031485036f8102ffce5a5942054c9f51d28dc9bcb3
7
+ data.tar.gz: b281a14ab6d5bfa7cfbfa48f9012daad168ab87ed6bc3bfa2d25c89d581d0127908e5b4fa5e603d427b13de78f770d6815d2bd1d0a0dd7f05231495487f42c28
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.2.2
1
+ FROM ruby:2.3
2
2
 
3
3
  RUN mkdir -p /u/app
4
4
  WORKDIR /u/app
@@ -0,0 +1,6 @@
1
+ dependencies:
2
+ pre:
3
+ - gem install bundler --version 1.11
4
+ machine:
5
+ ruby:
6
+ version: 2.3.0
@@ -19,7 +19,7 @@ This is an attempt to use Ruby parse them into an object graph which can
19
19
  be investigated programatically, manipulated, validated or printed into
20
20
  some canonical form.
21
21
  EOD
22
- spec.homepage = "http://barkingiguana.com/"
22
+ spec.homepage = "https://github.com/craigw/dns-zonefile"
23
23
 
24
24
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
25
25
  # delete this section to allow pushing this gem to any host.
@@ -51,6 +51,7 @@ module DNS
51
51
  when 'PTR' then @records << PTR.new(@vars, e)
52
52
  when 'SRV' then @records << SRV.new(@vars, e)
53
53
  when 'SPF' then @records << SPF.new(@vars, e)
54
+ when 'SSHFP' then @records << SSHFP.new(@vars, e)
54
55
  when 'TXT' then @records << TXT.new(@vars, e)
55
56
  when 'SOA' then ;
56
57
  else
@@ -70,34 +71,6 @@ module DNS
70
71
  end
71
72
 
72
73
  class Record
73
- # assign, with handling for '@'
74
- def self.writer_for_at(*attribs)
75
- attribs.each do |attrib|
76
- c = <<-MTH
77
- def #{attrib}=(val)
78
- @#{attrib} = val.gsub('@', @vars['origin'])
79
- end
80
- MTH
81
- class_eval c, __FILE__, __LINE__
82
- end
83
- end
84
-
85
- # assign, with handling for '@', with inheritance
86
- def self.inheriting_writer_for_at(*attribs)
87
- attribs.each do |attrib|
88
- c = <<-MTH
89
- def #{attrib}=(val)
90
- if val.strip.empty?
91
- @#{attrib} = @vars[:last_host]
92
- else
93
- @#{attrib} = val.gsub('@', @vars['origin'])
94
- end
95
- end
96
- MTH
97
- class_eval c, __FILE__, __LINE__
98
- end
99
- end
100
-
101
74
  # assign, with handling for global TTL
102
75
  def self.writer_for_ttl(*attribs)
103
76
  attribs.each do |attrib|
@@ -119,22 +92,37 @@ module DNS
119
92
  @klass ||= 'IN'
120
93
  end
121
94
 
95
+ private
96
+ def qualify_host(host)
97
+ origin = vars['origin']
98
+ host = vars[:last_host] if host =~ /^\s*$/
99
+ host = host.gsub(/@/, origin)
100
+ if host =~ /\.$/
101
+ host
102
+ else
103
+ if origin =~ /^\./
104
+ host + origin
105
+ else
106
+ host + "." + origin
107
+ end
108
+ end
109
+ end
110
+ attr_accessor :vars
111
+
122
112
  end
123
113
 
124
114
  class SOA < Record
125
115
  attr_accessor :origin, :nameserver, :responsible_party, :serial, :refresh_time, :retry_time, :expiry_time, :nxttl
126
116
 
127
- writer_for_at :origin, :nameserver, :responsible_party
128
-
129
117
  def initialize(vars, zonefile_soa=nil)
130
118
  @vars = vars
131
119
  if zonefile_soa
132
- self.origin = zonefile_soa.origin.to_s
120
+ self.origin = qualify_host(zonefile_soa.origin.to_s)
133
121
  @vars[:last_host] = self.origin
134
122
  self.ttl = zonefile_soa.ttl.to_i
135
123
  self.klass = zonefile_soa.klass.to_s
136
- self.nameserver = zonefile_soa.ns.to_s
137
- self.responsible_party = zonefile_soa.rp.to_s
124
+ self.nameserver = qualify_host(zonefile_soa.ns.to_s)
125
+ self.responsible_party = qualify_host(zonefile_soa.rp.to_s)
138
126
  self.serial = zonefile_soa.serial.to_i
139
127
  self.refresh_time = zonefile_soa.refresh.to_i
140
128
  self.retry_time = zonefile_soa.reretry.to_i
@@ -147,12 +135,10 @@ module DNS
147
135
  class A < Record
148
136
  attr_accessor :host, :address
149
137
 
150
- inheriting_writer_for_at :host
151
-
152
138
  def initialize(vars, zonefile_record)
153
139
  @vars = vars
154
140
  if zonefile_record
155
- self.host = zonefile_record.host.to_s
141
+ self.host = qualify_host(zonefile_record.host.to_s)
156
142
  @vars[:last_host] = self.host
157
143
  self.ttl = zonefile_record.ttl.to_i
158
144
  self.klass = zonefile_record.klass.to_s
@@ -167,17 +153,14 @@ module DNS
167
153
  class CNAME < Record
168
154
  attr_accessor :host, :domainname
169
155
 
170
- inheriting_writer_for_at :host
171
- writer_for_at :domainname
172
-
173
156
  def initialize(vars, zonefile_record)
174
157
  @vars = vars
175
158
  if zonefile_record
176
- self.host = zonefile_record.host.to_s
159
+ self.host = qualify_host(zonefile_record.host.to_s)
177
160
  @vars[:last_host] = self.host
178
161
  self.ttl = zonefile_record.ttl.to_i
179
162
  self.klass = zonefile_record.klass.to_s
180
- self.domainname = zonefile_record.target.to_s
163
+ self.domainname = qualify_host(zonefile_record.target.to_s)
181
164
  end
182
165
  end
183
166
 
@@ -188,18 +171,15 @@ module DNS
188
171
  class MX < Record
189
172
  attr_accessor :host, :priority, :domainname
190
173
 
191
- inheriting_writer_for_at :host
192
- writer_for_at :domainname
193
-
194
174
  def initialize(vars, zonefile_record)
195
175
  @vars = vars
196
176
  if zonefile_record
197
- self.host = zonefile_record.host.to_s
177
+ self.host = qualify_host(zonefile_record.host.to_s)
198
178
  @vars[:last_host] = self.host
199
179
  self.ttl = zonefile_record.ttl.to_i
200
180
  self.klass = zonefile_record.klass.to_s
201
181
  self.priority = zonefile_record.priority.to_i
202
- self.domainname = zonefile_record.exchanger.to_s
182
+ self.domainname = qualify_host(zonefile_record.exchanger.to_s)
203
183
  end
204
184
  end
205
185
 
@@ -210,12 +190,10 @@ module DNS
210
190
  class NAPTR < Record
211
191
  attr_accessor :host, :data
212
192
 
213
- inheriting_writer_for_at :host
214
-
215
193
  def initialize(vars, zonefile_record)
216
194
  @vars = vars
217
195
  if zonefile_record
218
- self.host = zonefile_record.host.to_s
196
+ self.host = qualify_host(zonefile_record.host.to_s)
219
197
  @vars[:last_host] = self.host
220
198
  self.ttl = zonefile_record.ttl.to_i
221
199
  self.klass = zonefile_record.klass.to_s
@@ -227,17 +205,14 @@ module DNS
227
205
  class NS < Record
228
206
  attr_accessor :host, :domainname
229
207
 
230
- inheriting_writer_for_at :host
231
- writer_for_at :domainname
232
-
233
208
  def initialize(vars, zonefile_record)
234
209
  @vars = vars
235
210
  if zonefile_record
236
- self.host = zonefile_record.host.to_s
211
+ self.host = qualify_host(zonefile_record.host.to_s)
237
212
  @vars[:last_host] = self.host
238
213
  self.ttl = zonefile_record.ttl.to_i
239
214
  self.klass = zonefile_record.klass.to_s
240
- self.domainname = zonefile_record.nameserver.to_s
215
+ self.domainname = qualify_host(zonefile_record.nameserver.to_s)
241
216
  end
242
217
  end
243
218
 
@@ -247,17 +222,14 @@ module DNS
247
222
  class PTR < Record
248
223
  attr_accessor :host, :domainname
249
224
 
250
- inheriting_writer_for_at :host
251
- writer_for_at :domainname
252
-
253
225
  def initialize(vars, zonefile_record)
254
226
  @vars = vars
255
227
  if zonefile_record
256
- self.host = zonefile_record.host.to_s
228
+ self.host = qualify_host(zonefile_record.host.to_s)
257
229
  @vars[:last_host] = self.host
258
230
  self.ttl = zonefile_record.ttl.to_i
259
231
  self.klass = zonefile_record.klass.to_s
260
- self.domainname = zonefile_record.target.to_s
232
+ self.domainname = qualify_host(zonefile_record.target.to_s)
261
233
  end
262
234
  end
263
235
 
@@ -267,35 +239,47 @@ module DNS
267
239
  class SRV < Record
268
240
  attr_accessor :host, :priority, :weight, :port, :domainname
269
241
 
270
- inheriting_writer_for_at :host
271
- writer_for_at :domainname
272
-
273
242
  def initialize(vars, zonefile_record)
274
243
  @vars = vars
275
244
  if zonefile_record
276
- self.host = zonefile_record.host.to_s
245
+ self.host = qualify_host(zonefile_record.host.to_s)
277
246
  @vars[:last_host] = self.host
278
247
  self.ttl = zonefile_record.ttl.to_i
279
248
  self.klass = zonefile_record.klass.to_s
280
249
  self.priority = zonefile_record.priority.to_i
281
250
  self.weight = zonefile_record.weight.to_i
282
251
  self.port = zonefile_record.port.to_i
283
- self.domainname = zonefile_record.target.to_s
252
+ self.domainname = qualify_host(zonefile_record.target.to_s)
284
253
  end
285
254
  end
286
255
 
287
256
  alias :target :domainname
288
257
  end
289
258
 
259
+ class SSHFP < Record
260
+ attr_accessor :host, :alg, :fptype, :fp
261
+
262
+ def initialize(vars, zonefile_record)
263
+ @vars = vars
264
+ if zonefile_record
265
+ self.host = qualify_host(zonefile_record.host.to_s)
266
+ @vars[:last_host] = self.host
267
+ self.ttl = zonefile_record.ttl.to_i
268
+ self.klass = zonefile_record.klass.to_s
269
+ self.alg = zonefile_record.alg.to_i
270
+ self.fptype = zonefile_record.fptype.to_i
271
+ self.fp = zonefile_record.fp.to_s
272
+ end
273
+ end
274
+ end
275
+
290
276
  class TXT < Record
291
277
  attr_accessor :host, :data
292
278
 
293
- inheriting_writer_for_at :host
294
-
295
279
  def initialize(vars, zonefile_record)
296
280
  @vars = vars
297
281
  if zonefile_record
298
- self.host = zonefile_record.host.to_s
282
+ self.host = qualify_host(zonefile_record.host.to_s)
299
283
  @vars[:last_host] = self.host
300
284
  self.ttl = zonefile_record.ttl.to_i
301
285
  self.klass = zonefile_record.klass.to_s
@@ -53,7 +53,7 @@ grammar Zonefile
53
53
  end
54
54
 
55
55
  rule resource_record
56
- record:(a_record / aaaa_record / cname_record / mx_record / naptr_record / ns_record / ptr_record / srv_record / spf_record / txt_record / soa_record) space* comment? linebreak {
56
+ record:(a_record / aaaa_record / cname_record / mx_record / naptr_record / ns_record / ptr_record / srv_record / spf_record / sshfp_record / txt_record / soa_record) space* comment? linebreak {
57
57
  def zone
58
58
  p = parent
59
59
  while p.respond_to?(:parent) && p.parent
@@ -221,7 +221,7 @@ grammar Zonefile
221
221
  end
222
222
  }
223
223
  end
224
-
224
+
225
225
  rule spf_record
226
226
  host space ms_age ttl klass "SPF" space data:txt_data {
227
227
  def to_s
@@ -233,7 +233,19 @@ grammar Zonefile
233
233
  end
234
234
  }
235
235
  end
236
-
236
+
237
+ rule sshfp_record
238
+ host space ms_age ttl klass "SSHFP" space alg:integer space fptype:integer space fp:fingerprint {
239
+ def to_s
240
+ "#{host} #{ttl} #{klass} SSHFP #{alg} #{fptype} #{fp}"
241
+ end
242
+
243
+ def record_type
244
+ "SSHFP"
245
+ end
246
+ }
247
+ end
248
+
237
249
  rule txt_record
238
250
  host space ms_age ttl klass "TXT" space data:ms_txt_data {
239
251
  def to_s
@@ -436,14 +448,15 @@ grammar Zonefile
436
448
  rule host
437
449
  ( ([*a-zA-Z0-9\-\._]+) / "@" / ' ' / "\t" ) {
438
450
  def to_s
439
- case text_value
440
- when /\.$/
441
- text_value
442
- when "@", /\s/
443
- text_value
444
- else
445
- text_value + '.@'
446
- end
451
+ text_value
452
+ end
453
+ }
454
+ end
455
+
456
+ rule fingerprint
457
+ [a-fA-Z0-9:]+ {
458
+ def to_s
459
+ text_value.strip
447
460
  end
448
461
  }
449
462
  end
@@ -1,5 +1,5 @@
1
1
  module DNS
2
2
  module Zonefile
3
- VERSION = "1.1.2"
3
+ VERSION = "1.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dns-zonefile
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig R Webster
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-07 00:00:00.000000000 Z
11
+ date: 2016-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop
@@ -96,7 +96,6 @@ extra_rdoc_files: []
96
96
  files:
97
97
  - ".gitignore"
98
98
  - ".rspec"
99
- - ".travis.yml"
100
99
  - Dockerfile
101
100
  - Gemfile
102
101
  - LICENCE
@@ -105,6 +104,7 @@ files:
105
104
  - TODO
106
105
  - bin/console
107
106
  - bin/setup
107
+ - circle.yml
108
108
  - dns-zonefile.gemspec
109
109
  - doc/example.com.zone
110
110
  - doc/example2.com.zone
@@ -114,7 +114,7 @@ files:
114
114
  - lib/dns/zonefile.rb
115
115
  - lib/dns/zonefile.treetop
116
116
  - lib/dns/zonefile/version.rb
117
- homepage: http://barkingiguana.com/
117
+ homepage: https://github.com/craigw/dns-zonefile
118
118
  licenses: []
119
119
  metadata:
120
120
  allowed_push_host: https://rubygems.org
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.4
4
- before_install: gem install bundler -v 1.11.2