dns-zone 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ce394f29889d56814fe99dee138535282dc7031f
4
- data.tar.gz: bee58379e2fdc3d33219b7dc95c0c6a4156f557f
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MmY5NGU3NjIwYmU4ZDg1NjcyNGZkOTgwYjQ4ZGVmZmE5MjIzOTZiZQ==
5
+ data.tar.gz: !binary |-
6
+ OTVkNzhjM2MyZjIzOWMzNTBmZjFhNjBiOTNjOTZiNjY3YmY0NzIzMA==
5
7
  SHA512:
6
- metadata.gz: b323d369cd33d0bdc2e2ad82b1cd9d4a39681ea1f7676cc25f048f0d3e946fc3d7d45c1cb2febe1aed622f2912ca484dc17d3459541617fd8cbb1f657752e1c8
7
- data.tar.gz: 5560b853bf4ffb3883e842c6c90b7dd2dd6c2aa4163339afe16a3e085a75594b8a5c3aaddfb2244dc6a81d0ac6a82be126944f215c802a4553f35530df5c7f57
8
+ metadata.gz: !binary |-
9
+ YWFhZDY4OTc3YzYwM2E0OWUwZTIwY2E2YjRlYjM3MTEwZWRlNjljZmEzZGE1
10
+ YmQ2YzhjYWQyYTg0MzMzNDNkMWE5MWY5ZGVjODAwNjlmZWRjZmIyNGIwODZm
11
+ MGNlMjgzOTU2YWUyNzAzYjhjNzNlMjg5MTYxZTU4NDBhZmJlOTE=
12
+ data.tar.gz: !binary |-
13
+ OGRjMWExODhlZTFhMTE5ZTI4MjllYWNmZjAxZTg3NDk4NzQ4YmUxNGY3Njhk
14
+ YjE4NmMxNDRlNDFmODE2OTEzNjYyMmRmZjQ2MDI0ZDlkOWJjMmNlNTk0OWUy
15
+ Yzk3M2NmNjEwMjY4MGZmYmZmNTMyZWMyODFkMGNkZjUxOThjMjU=
data/HISTORY.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## HEAD
2
2
 
3
+ ## 0.3.0 (2015-12-23)
4
+
5
+ * Requires Ruby version >= 2.0
6
+ * Ability to parse zone file with multiple `ORIGIN` directives.
7
+
3
8
  ## 0.2.0 (2015-10-20)
4
9
 
5
10
  Development sponsored by Peter J. Philipp [centroid.eu](http://centroid.eu)
data/README.md CHANGED
@@ -116,7 +116,6 @@ Special thanks to Peter J. Philipp [centroid.eu](http://centroid.eu) for sponsor
116
116
 
117
117
  ## Would be nice
118
118
 
119
- [ ] Handle parsing a zone file that uses more then one $ORIGIN directive.
120
119
  [ ] Basic validation, error checking:
121
120
  [ ] Only one SOA per zone.
122
121
  [ ] CNAMEs can't use a label of `@`.
@@ -19,7 +19,7 @@ spec = Gem::Specification.new do |s|
19
19
  #s.default_executable = 'dns-zone'
20
20
 
21
21
  # min ruby version
22
- #s.required_ruby_version = ::Gem::Requirement.new(">= 1.9")
22
+ s.required_ruby_version = ::Gem::Requirement.new(">= 2.0")
23
23
 
24
24
  # cross platform gem dependencies
25
25
  #s.add_dependency('gli')
@@ -92,7 +92,11 @@ module DNS
92
92
  # read in special statments like $TTL and $ORIGIN
93
93
  if entry =~ /\$(ORIGIN|TTL)\s+(.+)/
94
94
  instance.ttl = $2 if $1 == 'TTL'
95
- instance.origin = $2 if $1 == 'ORIGIN'
95
+ if $1 == 'ORIGIN'
96
+ instance.origin ||= $2
97
+ options[:origin] ||= $2
98
+ options[:last_origin] = $2
99
+ end
96
100
  next
97
101
  end
98
102
 
@@ -75,6 +75,10 @@ class DNS::Zone::RR::Record
75
75
  @label = captures[:label]
76
76
  end
77
77
 
78
+ # unroll records nested under other origins
79
+ unrolled_origin = options[:last_origin].sub(options[:origin], '').chomp('.') if options[:last_origin]
80
+ @label = "#{@label}.#{unrolled_origin}" if unrolled_origin && !unrolled_origin.empty?
81
+
78
82
  @ttl = captures[:ttl]
79
83
  captures[:rdata]
80
84
  end
@@ -1,6 +1,6 @@
1
1
  module DNS
2
2
  class Zone
3
3
  # Version number (major.minor.tiny)
4
- Version = '0.2.0'
4
+ Version = '0.3.0'
5
5
  end
6
6
  end
@@ -57,6 +57,36 @@ EOL
57
57
  @ IN MX 99 mx.fakemx.net.
58
58
  @ IN A 78.47.253.85
59
59
  mail IN A 78.47.253.85
60
+ EOL
61
+
62
+ # zone file with multiple zones
63
+ ZONE_FILE_MULTIPLE_ORIGINS_EXAMPLE =<<-EOL
64
+ $ORIGIN lividpenguin.com.
65
+ $TTL 3d
66
+ @ IN SOA ns0.lividpenguin.com. luke.lividpenguin.com. (
67
+ 2013101406 ; zone serial number
68
+ 12h ; refresh ttl
69
+ 15m ; retry ttl
70
+ 3w ; expiry ttl
71
+ 3h ; minimum ttl
72
+ )
73
+
74
+ @ IN NS ns0.lividpenguin.com.
75
+ @ IN NS ns1.lividpenguin.com.
76
+ @ IN NS ns2.lividpenguin.com.
77
+
78
+ @ IN A 78.47.253.85
79
+ www IN A 78.47.253.85
80
+
81
+ foo IN TXT "part1""part2"
82
+
83
+ $ORIGIN sub.lividpenguin.com.
84
+ app1 60 A 1.2.3.4
85
+ app2 60 A 1.2.3.5
86
+ app3 60 A 1.2.3.6
87
+ $ORIGIN another.lividpenguin.com.
88
+ app1 60 A 4.3.2.1
89
+
60
90
  EOL
61
91
 
62
92
  def test_create_new_instance
@@ -101,6 +131,14 @@ EOL
101
131
  assert_equal 'lividpenguin.com.', zone.origin, 'origin should come from test zone, not passed param'
102
132
  end
103
133
 
134
+ def test_load_zone_labels_are_correct
135
+ zone = DNS::Zone.load(ZONE_FILE_BASIC_EXAMPLE, 'lividpenguin.com.')
136
+ assert_equal 'mail', zone.records[5].label, 'check label is correct'
137
+
138
+ zone = DNS::Zone.load(ZONE_FILE_EXAMPLE)
139
+ assert_equal 'ns0', zone.records[7].label, 'check label is correct'
140
+ end
141
+
104
142
  def test_load_zone
105
143
  # load example dns master zone file.
106
144
  zone = DNS::Zone.load(ZONE_FILE_EXAMPLE)
@@ -149,6 +187,16 @@ EOL
149
187
  assert_equal '78.47.253.85', record.address
150
188
  end
151
189
 
190
+ def test_load_multiple_origins
191
+ zone = DNS::Zone.load(ZONE_FILE_MULTIPLE_ORIGINS_EXAMPLE)
192
+ assert_equal 'lividpenguin.com.', zone.origin
193
+ assert_equal 11, zone.records.length, 'we should have multiple records (including SOA)'
194
+ assert_equal 'app1.sub', zone.records[7].label
195
+ assert_equal '1.2.3.4', zone.records[7].address
196
+ assert_equal 'app1.another', zone.records[10].label
197
+ assert_equal '4.3.2.1', zone.records[10].address
198
+ end
199
+
152
200
  def test_extract_entry_from_one_line
153
201
  entries = DNS::Zone.extract_entries(%Q{maiow IN TXT "purr"})
154
202
  assert_equal 1, entries.length, 'we should have 1 entry'
metadata CHANGED
@@ -1,130 +1,132 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dns-zone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Antins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-20 00:00:00.000000000 Z
11
+ date: 2015-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '9.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '9.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '5.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: simplecov
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.7.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.7.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0.8'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.8'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: inch
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0.6'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.6'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: guard-minitest
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: '2.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: '2.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: guard-bundler
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ~>
116
116
  - !ruby/object:Gem::Version
117
117
  version: '2.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ~>
123
123
  - !ruby/object:Gem::Version
124
124
  version: '2.0'
125
- description: |
126
- A Ruby library for building and parsing DNS zone files for use with
125
+ description: ! 'A Ruby library for building and parsing DNS zone files for use with
126
+
127
127
  Bind and PowerDNS (with Bind backend) DNS servers.
128
+
129
+ '
128
130
  email:
129
131
  - luke@lividpenguin.com
130
132
  executables: []
@@ -199,19 +201,18 @@ require_paths:
199
201
  - lib
200
202
  required_ruby_version: !ruby/object:Gem::Requirement
201
203
  requirements:
202
- - - ">="
204
+ - - ! '>='
203
205
  - !ruby/object:Gem::Version
204
- version: '0'
206
+ version: '2.0'
205
207
  required_rubygems_version: !ruby/object:Gem::Requirement
206
208
  requirements:
207
- - - ">="
209
+ - - ! '>='
208
210
  - !ruby/object:Gem::Version
209
211
  version: '0'
210
212
  requirements: []
211
213
  rubyforge_project:
212
- rubygems_version: 2.4.2
214
+ rubygems_version: 2.2.2
213
215
  signing_key:
214
216
  specification_version: 4
215
217
  summary: A Ruby library for building and parsing DNS zone files.
216
218
  test_files: []
217
- has_rdoc: