dns-zonefile 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  *.gem
2
2
  .rvmrc
3
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - ruby-head
4
+ - 1.9.3
5
+ - 1.9.2
6
+ - 1.8.7
7
+ - ree
@@ -1,65 +1,61 @@
1
- DNS::Zonefile
2
- =============
1
+ # DNS::Zonefile
3
2
 
4
3
  The format of a DNS Zonefile is defined in RFC 1035 section 5 and RFC
5
- 1034 section 3.6.1. To anyone who's using BIND they'll look very
4
+ 1034 section 3.6.1. To anyone who's using BIND they'll look very
6
5
  familiar.
7
6
 
8
- This is an attempt to use Ruby parse them into an object graph which can
9
- be investigated programatically, manipulated, validated or printed into
7
+ This is an attempt to use Ruby parse them into an object graph which can
8
+ be investigated programatically, manipulated, validated or printed into
10
9
  some canonical form.
11
10
 
12
11
 
13
- Getting setup
14
- -------------
12
+ ## Getting setup
15
13
 
16
- Well, you'll need the treetop and polyglot gems installed. They do all
14
+ Well, you'll need the treetop and polyglot gems installed. They do all
17
15
  the hard work. Thanks!
18
16
 
19
- sudo gem install treetop polyglot
17
+ sudo gem install treetop polyglot
20
18
 
21
- Now you'll need to generate the Treetop parser from the Zonefile grammar
19
+ Now you'll need to generate the Treetop parser from the Zonefile grammar
22
20
  that I've hacked together.
23
21
 
24
- rake generate_grammar
22
+ rake generate_grammar
25
23
 
26
24
  Okay, you're ready to move onto the examples now.
27
25
 
28
26
  The above steps should not be necessary if you install the gem via rubygems.
29
27
 
30
28
 
31
- Examples
32
- --------
29
+ ## Examples
33
30
 
34
31
  Using raw data from the parser. Note that "@" isn't translated in this mode.
35
32
  Nor are inherited TTLs interpreted.
36
33
 
37
- zonefile = "/path/to/file.zone"
38
- zone_string = File.read(zonefile)
39
- zone = DNS::Zonefile.parse(zone_string)
34
+ zonefile = "/path/to/file.zone"
35
+ zone_string = File.read(zonefile)
36
+ zone = DNS::Zonefile.parse(zone_string)
40
37
 
41
- puts zone.soa.origin.to_s
42
- puts zone.soa.ns.to_s
43
- puts zone.rr[0].to_s
38
+ puts zone.soa.origin.to_s
39
+ puts zone.soa.ns.to_s
40
+ puts zone.rr[0].to_s
44
41
 
45
42
  Using more structure data. @, TTLs, and empty hostname inheritance are all
46
43
  handled in this mode.
47
44
 
48
- zonefile = "/path/to/file.zone"
49
- zone_string = File.read(zonefile)
50
- zone = DNS::Zonefile.load(zone_string)
51
- # or, if no $origin is in the zone file
52
- zone = DNS::Zonefile.load(zone_string, 'example.com.')
45
+ zonefile = "/path/to/file.zone"
46
+ zone_string = File.read(zonefile)
47
+ zone = DNS::Zonefile.load(zone_string)
48
+ # or, if no $origin is in the zone file
49
+ zone = DNS::Zonefile.load(zone_string, 'example.com.')
53
50
 
54
- puts zone.soa.origin
55
- puts zone.soa.nameserver
56
- puts zone.records[1]
57
- # get all MX records
58
- puts zone.records_of(DNS::MX)
51
+ puts zone.soa.origin
52
+ puts zone.soa.nameserver
53
+ puts zone.records[1]
54
+ # get all MX records
55
+ puts zone.records_of(DNS::Zonefile::MX)
59
56
 
60
57
 
61
- Authors
62
- -------
58
+ ## Authors
63
59
 
64
60
  Original code and concept:
65
61
  Craig R Webster <http://barkingiguana.com/>
@@ -68,8 +64,9 @@ Additions:
68
64
  t.e.morgan <http://zerigo.com/>
69
65
 
70
66
 
71
- Contributing
72
- ------------
67
+ ## Contributing
73
68
 
74
- See the TODO. Send me patches or pull request either by email or on
75
- GitHub.
69
+ See the TODO. Send me patches or pull request either by email or on
70
+ GitHub.
71
+
72
+ [![Build Status](https://secure.travis-ci.org/craigw/dns-zonefile.png)](http://travis-ci.org/craigw/dns-zonefile)
data/TODO CHANGED
@@ -2,3 +2,5 @@
2
2
  * Output the zone object-graph as a zone string.
3
3
  * Allow comparison of resource records and zones for checking equality.
4
4
  * Allow unqualified ns and rp in SOA
5
+ * Implement the changes in the eam pull request for other record types:
6
+ https://github.com/craigw/dns-zonefile/pull/1
data/dns-zonefile.gemspec CHANGED
@@ -10,11 +10,11 @@ Gem::Specification.new do |s|
10
10
  s.homepage = ""
11
11
  s.summary = %q{Work with zonefiles (RFC 1035 section 5 and RFC 1034 section 3.6.1)}
12
12
  s.description = %q{The format of a DNS Zonefile is defined in RFC 1035 section 5 and RFC
13
- 1034 section 3.6.1. To anyone who's using BIND they'll look very
13
+ 1034 section 3.6.1. To anyone who's using BIND they'll look very
14
14
  familiar.
15
15
 
16
- This is an attempt to use Ruby parse them into an object graph which can
17
- be investigated programatically, manipulated, validated or printed into
16
+ This is an attempt to use Ruby parse them into an object graph which can
17
+ be investigated programatically, manipulated, validated or printed into
18
18
  some canonical form.}
19
19
 
20
20
  s.rubyforge_project = "dns-zonefile"
data/doc/zonefile.treetop CHANGED
@@ -121,7 +121,12 @@ grammar Zonefile
121
121
  end
122
122
 
123
123
  rule cname_record
124
- host space ttl klass "CNAME" space target:host {
124
+ (
125
+ host space ttl klass "CNAME" space target:host /
126
+ host space klass ttl "CNAME" space target:host /
127
+ host space ttl "CNAME" space target:host /
128
+ host space klass "CNAME" space target:host
129
+ ) {
125
130
  def to_s
126
131
  "#{host} #{ttl} #{klass} CNAME #{target}"
127
132
  end
@@ -169,7 +174,12 @@ grammar Zonefile
169
174
  end
170
175
 
171
176
  rule srv_record
172
- host space ttl klass "SRV" space priority:integer space weight:integer space port:integer space target:host {
177
+ (
178
+ host space ttl klass "SRV" space priority:integer space weight:integer space port:integer space target:host /
179
+ host space klass ttl "SRV" space priority:integer space weight:integer space port:integer space target:host /
180
+ host space ttl "SRV" space priority:integer space weight:integer space port:integer space target:host /
181
+ host space klass "SRV" space priority:integer space weight:integer space port:integer space target:host
182
+ ) {
173
183
  def to_s
174
184
  "#{host} #{ttl} #{klass} SRV #{priority} #{weight} #{port} #{target}"
175
185
  end
@@ -249,7 +259,7 @@ grammar Zonefile
249
259
  end
250
260
 
251
261
  rule rp
252
- (("\\." / [a-zA-Z0-9\-)])+ ".")+ {
262
+ (("\\." / [+a-zA-Z0-9\-)])+ ".")+ {
253
263
  def to_s
254
264
  text_value
255
265
  end
@@ -1082,6 +1082,76 @@ module DNS
1082
1082
  end
1083
1083
 
1084
1084
  module CnameRecord1
1085
+ def host
1086
+ elements[0]
1087
+ end
1088
+
1089
+ def space1
1090
+ elements[1]
1091
+ end
1092
+
1093
+ def klass
1094
+ elements[2]
1095
+ end
1096
+
1097
+ def ttl
1098
+ elements[3]
1099
+ end
1100
+
1101
+ def space2
1102
+ elements[5]
1103
+ end
1104
+
1105
+ def target
1106
+ elements[6]
1107
+ end
1108
+ end
1109
+
1110
+ module CnameRecord2
1111
+ def host
1112
+ elements[0]
1113
+ end
1114
+
1115
+ def space1
1116
+ elements[1]
1117
+ end
1118
+
1119
+ def ttl
1120
+ elements[2]
1121
+ end
1122
+
1123
+ def space2
1124
+ elements[4]
1125
+ end
1126
+
1127
+ def target
1128
+ elements[5]
1129
+ end
1130
+ end
1131
+
1132
+ module CnameRecord3
1133
+ def host
1134
+ elements[0]
1135
+ end
1136
+
1137
+ def space1
1138
+ elements[1]
1139
+ end
1140
+
1141
+ def klass
1142
+ elements[2]
1143
+ end
1144
+
1145
+ def space2
1146
+ elements[4]
1147
+ end
1148
+
1149
+ def target
1150
+ elements[5]
1151
+ end
1152
+ end
1153
+
1154
+ module CnameRecord4
1085
1155
  def to_s
1086
1156
  "#{host} #{ttl} #{klass} CNAME #{target}"
1087
1157
  end
@@ -1098,46 +1168,180 @@ module DNS
1098
1168
  return cached
1099
1169
  end
1100
1170
 
1101
- i0, s0 = index, []
1102
- r1 = _nt_host
1103
- s0 << r1
1104
- if r1
1105
- r2 = _nt_space
1106
- s0 << r2
1107
- if r2
1108
- r3 = _nt_ttl
1109
- s0 << r3
1110
- if r3
1111
- r4 = _nt_klass
1112
- s0 << r4
1113
- if r4
1171
+ i0 = index
1172
+ i1, s1 = index, []
1173
+ r2 = _nt_host
1174
+ s1 << r2
1175
+ if r2
1176
+ r3 = _nt_space
1177
+ s1 << r3
1178
+ if r3
1179
+ r4 = _nt_ttl
1180
+ s1 << r4
1181
+ if r4
1182
+ r5 = _nt_klass
1183
+ s1 << r5
1184
+ if r5
1114
1185
  if has_terminal?("CNAME", false, index)
1115
- r5 = instantiate_node(SyntaxNode,input, index...(index + 5))
1186
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 5))
1116
1187
  @index += 5
1117
1188
  else
1118
1189
  terminal_parse_failure("CNAME")
1119
- r5 = nil
1190
+ r6 = nil
1120
1191
  end
1121
- s0 << r5
1122
- if r5
1123
- r6 = _nt_space
1124
- s0 << r6
1125
- if r6
1126
- r7 = _nt_host
1127
- s0 << r7
1192
+ s1 << r6
1193
+ if r6
1194
+ r7 = _nt_space
1195
+ s1 << r7
1196
+ if r7
1197
+ r8 = _nt_host
1198
+ s1 << r8
1128
1199
  end
1129
1200
  end
1130
1201
  end
1131
1202
  end
1132
1203
  end
1133
1204
  end
1134
- if s0.last
1135
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1136
- r0.extend(CnameRecord0)
1137
- r0.extend(CnameRecord1)
1205
+ if s1.last
1206
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1207
+ r1.extend(CnameRecord0)
1138
1208
  else
1139
- @index = i0
1140
- r0 = nil
1209
+ @index = i1
1210
+ r1 = nil
1211
+ end
1212
+ if r1
1213
+ r0 = r1
1214
+ r0.extend(CnameRecord4)
1215
+ else
1216
+ i9, s9 = index, []
1217
+ r10 = _nt_host
1218
+ s9 << r10
1219
+ if r10
1220
+ r11 = _nt_space
1221
+ s9 << r11
1222
+ if r11
1223
+ r12 = _nt_klass
1224
+ s9 << r12
1225
+ if r12
1226
+ r13 = _nt_ttl
1227
+ s9 << r13
1228
+ if r13
1229
+ if has_terminal?("CNAME", false, index)
1230
+ r14 = instantiate_node(SyntaxNode,input, index...(index + 5))
1231
+ @index += 5
1232
+ else
1233
+ terminal_parse_failure("CNAME")
1234
+ r14 = nil
1235
+ end
1236
+ s9 << r14
1237
+ if r14
1238
+ r15 = _nt_space
1239
+ s9 << r15
1240
+ if r15
1241
+ r16 = _nt_host
1242
+ s9 << r16
1243
+ end
1244
+ end
1245
+ end
1246
+ end
1247
+ end
1248
+ end
1249
+ if s9.last
1250
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
1251
+ r9.extend(CnameRecord1)
1252
+ else
1253
+ @index = i9
1254
+ r9 = nil
1255
+ end
1256
+ if r9
1257
+ r0 = r9
1258
+ r0.extend(CnameRecord4)
1259
+ else
1260
+ i17, s17 = index, []
1261
+ r18 = _nt_host
1262
+ s17 << r18
1263
+ if r18
1264
+ r19 = _nt_space
1265
+ s17 << r19
1266
+ if r19
1267
+ r20 = _nt_ttl
1268
+ s17 << r20
1269
+ if r20
1270
+ if has_terminal?("CNAME", false, index)
1271
+ r21 = instantiate_node(SyntaxNode,input, index...(index + 5))
1272
+ @index += 5
1273
+ else
1274
+ terminal_parse_failure("CNAME")
1275
+ r21 = nil
1276
+ end
1277
+ s17 << r21
1278
+ if r21
1279
+ r22 = _nt_space
1280
+ s17 << r22
1281
+ if r22
1282
+ r23 = _nt_host
1283
+ s17 << r23
1284
+ end
1285
+ end
1286
+ end
1287
+ end
1288
+ end
1289
+ if s17.last
1290
+ r17 = instantiate_node(SyntaxNode,input, i17...index, s17)
1291
+ r17.extend(CnameRecord2)
1292
+ else
1293
+ @index = i17
1294
+ r17 = nil
1295
+ end
1296
+ if r17
1297
+ r0 = r17
1298
+ r0.extend(CnameRecord4)
1299
+ else
1300
+ i24, s24 = index, []
1301
+ r25 = _nt_host
1302
+ s24 << r25
1303
+ if r25
1304
+ r26 = _nt_space
1305
+ s24 << r26
1306
+ if r26
1307
+ r27 = _nt_klass
1308
+ s24 << r27
1309
+ if r27
1310
+ if has_terminal?("CNAME", false, index)
1311
+ r28 = instantiate_node(SyntaxNode,input, index...(index + 5))
1312
+ @index += 5
1313
+ else
1314
+ terminal_parse_failure("CNAME")
1315
+ r28 = nil
1316
+ end
1317
+ s24 << r28
1318
+ if r28
1319
+ r29 = _nt_space
1320
+ s24 << r29
1321
+ if r29
1322
+ r30 = _nt_host
1323
+ s24 << r30
1324
+ end
1325
+ end
1326
+ end
1327
+ end
1328
+ end
1329
+ if s24.last
1330
+ r24 = instantiate_node(SyntaxNode,input, i24...index, s24)
1331
+ r24.extend(CnameRecord3)
1332
+ else
1333
+ @index = i24
1334
+ r24 = nil
1335
+ end
1336
+ if r24
1337
+ r0 = r24
1338
+ r0.extend(CnameRecord4)
1339
+ else
1340
+ @index = i0
1341
+ r0 = nil
1342
+ end
1343
+ end
1344
+ end
1141
1345
  end
1142
1346
 
1143
1347
  node_cache[:cname_record][start_index] = r0
@@ -1694,6 +1898,148 @@ module DNS
1694
1898
  end
1695
1899
 
1696
1900
  module SrvRecord1
1901
+ def host
1902
+ elements[0]
1903
+ end
1904
+
1905
+ def space1
1906
+ elements[1]
1907
+ end
1908
+
1909
+ def klass
1910
+ elements[2]
1911
+ end
1912
+
1913
+ def ttl
1914
+ elements[3]
1915
+ end
1916
+
1917
+ def space2
1918
+ elements[5]
1919
+ end
1920
+
1921
+ def priority
1922
+ elements[6]
1923
+ end
1924
+
1925
+ def space3
1926
+ elements[7]
1927
+ end
1928
+
1929
+ def weight
1930
+ elements[8]
1931
+ end
1932
+
1933
+ def space4
1934
+ elements[9]
1935
+ end
1936
+
1937
+ def port
1938
+ elements[10]
1939
+ end
1940
+
1941
+ def space5
1942
+ elements[11]
1943
+ end
1944
+
1945
+ def target
1946
+ elements[12]
1947
+ end
1948
+ end
1949
+
1950
+ module SrvRecord2
1951
+ def host
1952
+ elements[0]
1953
+ end
1954
+
1955
+ def space1
1956
+ elements[1]
1957
+ end
1958
+
1959
+ def ttl
1960
+ elements[2]
1961
+ end
1962
+
1963
+ def space2
1964
+ elements[4]
1965
+ end
1966
+
1967
+ def priority
1968
+ elements[5]
1969
+ end
1970
+
1971
+ def space3
1972
+ elements[6]
1973
+ end
1974
+
1975
+ def weight
1976
+ elements[7]
1977
+ end
1978
+
1979
+ def space4
1980
+ elements[8]
1981
+ end
1982
+
1983
+ def port
1984
+ elements[9]
1985
+ end
1986
+
1987
+ def space5
1988
+ elements[10]
1989
+ end
1990
+
1991
+ def target
1992
+ elements[11]
1993
+ end
1994
+ end
1995
+
1996
+ module SrvRecord3
1997
+ def host
1998
+ elements[0]
1999
+ end
2000
+
2001
+ def space1
2002
+ elements[1]
2003
+ end
2004
+
2005
+ def klass
2006
+ elements[2]
2007
+ end
2008
+
2009
+ def space2
2010
+ elements[4]
2011
+ end
2012
+
2013
+ def priority
2014
+ elements[5]
2015
+ end
2016
+
2017
+ def space3
2018
+ elements[6]
2019
+ end
2020
+
2021
+ def weight
2022
+ elements[7]
2023
+ end
2024
+
2025
+ def space4
2026
+ elements[8]
2027
+ end
2028
+
2029
+ def port
2030
+ elements[9]
2031
+ end
2032
+
2033
+ def space5
2034
+ elements[10]
2035
+ end
2036
+
2037
+ def target
2038
+ elements[11]
2039
+ end
2040
+ end
2041
+
2042
+ module SrvRecord4
1697
2043
  def to_s
1698
2044
  "#{host} #{ttl} #{klass} SRV #{priority} #{weight} #{port} #{target}"
1699
2045
  end
@@ -1710,51 +2056,52 @@ module DNS
1710
2056
  return cached
1711
2057
  end
1712
2058
 
1713
- i0, s0 = index, []
1714
- r1 = _nt_host
1715
- s0 << r1
1716
- if r1
1717
- r2 = _nt_space
1718
- s0 << r2
1719
- if r2
1720
- r3 = _nt_ttl
1721
- s0 << r3
1722
- if r3
1723
- r4 = _nt_klass
1724
- s0 << r4
1725
- if r4
2059
+ i0 = index
2060
+ i1, s1 = index, []
2061
+ r2 = _nt_host
2062
+ s1 << r2
2063
+ if r2
2064
+ r3 = _nt_space
2065
+ s1 << r3
2066
+ if r3
2067
+ r4 = _nt_ttl
2068
+ s1 << r4
2069
+ if r4
2070
+ r5 = _nt_klass
2071
+ s1 << r5
2072
+ if r5
1726
2073
  if has_terminal?("SRV", false, index)
1727
- r5 = instantiate_node(SyntaxNode,input, index...(index + 3))
2074
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 3))
1728
2075
  @index += 3
1729
2076
  else
1730
2077
  terminal_parse_failure("SRV")
1731
- r5 = nil
2078
+ r6 = nil
1732
2079
  end
1733
- s0 << r5
1734
- if r5
1735
- r6 = _nt_space
1736
- s0 << r6
1737
- if r6
1738
- r7 = _nt_integer
1739
- s0 << r7
1740
- if r7
1741
- r8 = _nt_space
1742
- s0 << r8
1743
- if r8
1744
- r9 = _nt_integer
1745
- s0 << r9
1746
- if r9
1747
- r10 = _nt_space
1748
- s0 << r10
1749
- if r10
1750
- r11 = _nt_integer
1751
- s0 << r11
1752
- if r11
1753
- r12 = _nt_space
1754
- s0 << r12
1755
- if r12
1756
- r13 = _nt_host
1757
- s0 << r13
2080
+ s1 << r6
2081
+ if r6
2082
+ r7 = _nt_space
2083
+ s1 << r7
2084
+ if r7
2085
+ r8 = _nt_integer
2086
+ s1 << r8
2087
+ if r8
2088
+ r9 = _nt_space
2089
+ s1 << r9
2090
+ if r9
2091
+ r10 = _nt_integer
2092
+ s1 << r10
2093
+ if r10
2094
+ r11 = _nt_space
2095
+ s1 << r11
2096
+ if r11
2097
+ r12 = _nt_integer
2098
+ s1 << r12
2099
+ if r12
2100
+ r13 = _nt_space
2101
+ s1 << r13
2102
+ if r13
2103
+ r14 = _nt_host
2104
+ s1 << r14
1758
2105
  end
1759
2106
  end
1760
2107
  end
@@ -1767,13 +2114,218 @@ module DNS
1767
2114
  end
1768
2115
  end
1769
2116
  end
1770
- if s0.last
1771
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1772
- r0.extend(SrvRecord0)
1773
- r0.extend(SrvRecord1)
2117
+ if s1.last
2118
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
2119
+ r1.extend(SrvRecord0)
1774
2120
  else
1775
- @index = i0
1776
- r0 = nil
2121
+ @index = i1
2122
+ r1 = nil
2123
+ end
2124
+ if r1
2125
+ r0 = r1
2126
+ r0.extend(SrvRecord4)
2127
+ else
2128
+ i15, s15 = index, []
2129
+ r16 = _nt_host
2130
+ s15 << r16
2131
+ if r16
2132
+ r17 = _nt_space
2133
+ s15 << r17
2134
+ if r17
2135
+ r18 = _nt_klass
2136
+ s15 << r18
2137
+ if r18
2138
+ r19 = _nt_ttl
2139
+ s15 << r19
2140
+ if r19
2141
+ if has_terminal?("SRV", false, index)
2142
+ r20 = instantiate_node(SyntaxNode,input, index...(index + 3))
2143
+ @index += 3
2144
+ else
2145
+ terminal_parse_failure("SRV")
2146
+ r20 = nil
2147
+ end
2148
+ s15 << r20
2149
+ if r20
2150
+ r21 = _nt_space
2151
+ s15 << r21
2152
+ if r21
2153
+ r22 = _nt_integer
2154
+ s15 << r22
2155
+ if r22
2156
+ r23 = _nt_space
2157
+ s15 << r23
2158
+ if r23
2159
+ r24 = _nt_integer
2160
+ s15 << r24
2161
+ if r24
2162
+ r25 = _nt_space
2163
+ s15 << r25
2164
+ if r25
2165
+ r26 = _nt_integer
2166
+ s15 << r26
2167
+ if r26
2168
+ r27 = _nt_space
2169
+ s15 << r27
2170
+ if r27
2171
+ r28 = _nt_host
2172
+ s15 << r28
2173
+ end
2174
+ end
2175
+ end
2176
+ end
2177
+ end
2178
+ end
2179
+ end
2180
+ end
2181
+ end
2182
+ end
2183
+ end
2184
+ end
2185
+ if s15.last
2186
+ r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
2187
+ r15.extend(SrvRecord1)
2188
+ else
2189
+ @index = i15
2190
+ r15 = nil
2191
+ end
2192
+ if r15
2193
+ r0 = r15
2194
+ r0.extend(SrvRecord4)
2195
+ else
2196
+ i29, s29 = index, []
2197
+ r30 = _nt_host
2198
+ s29 << r30
2199
+ if r30
2200
+ r31 = _nt_space
2201
+ s29 << r31
2202
+ if r31
2203
+ r32 = _nt_ttl
2204
+ s29 << r32
2205
+ if r32
2206
+ if has_terminal?("SRV", false, index)
2207
+ r33 = instantiate_node(SyntaxNode,input, index...(index + 3))
2208
+ @index += 3
2209
+ else
2210
+ terminal_parse_failure("SRV")
2211
+ r33 = nil
2212
+ end
2213
+ s29 << r33
2214
+ if r33
2215
+ r34 = _nt_space
2216
+ s29 << r34
2217
+ if r34
2218
+ r35 = _nt_integer
2219
+ s29 << r35
2220
+ if r35
2221
+ r36 = _nt_space
2222
+ s29 << r36
2223
+ if r36
2224
+ r37 = _nt_integer
2225
+ s29 << r37
2226
+ if r37
2227
+ r38 = _nt_space
2228
+ s29 << r38
2229
+ if r38
2230
+ r39 = _nt_integer
2231
+ s29 << r39
2232
+ if r39
2233
+ r40 = _nt_space
2234
+ s29 << r40
2235
+ if r40
2236
+ r41 = _nt_host
2237
+ s29 << r41
2238
+ end
2239
+ end
2240
+ end
2241
+ end
2242
+ end
2243
+ end
2244
+ end
2245
+ end
2246
+ end
2247
+ end
2248
+ end
2249
+ if s29.last
2250
+ r29 = instantiate_node(SyntaxNode,input, i29...index, s29)
2251
+ r29.extend(SrvRecord2)
2252
+ else
2253
+ @index = i29
2254
+ r29 = nil
2255
+ end
2256
+ if r29
2257
+ r0 = r29
2258
+ r0.extend(SrvRecord4)
2259
+ else
2260
+ i42, s42 = index, []
2261
+ r43 = _nt_host
2262
+ s42 << r43
2263
+ if r43
2264
+ r44 = _nt_space
2265
+ s42 << r44
2266
+ if r44
2267
+ r45 = _nt_klass
2268
+ s42 << r45
2269
+ if r45
2270
+ if has_terminal?("SRV", false, index)
2271
+ r46 = instantiate_node(SyntaxNode,input, index...(index + 3))
2272
+ @index += 3
2273
+ else
2274
+ terminal_parse_failure("SRV")
2275
+ r46 = nil
2276
+ end
2277
+ s42 << r46
2278
+ if r46
2279
+ r47 = _nt_space
2280
+ s42 << r47
2281
+ if r47
2282
+ r48 = _nt_integer
2283
+ s42 << r48
2284
+ if r48
2285
+ r49 = _nt_space
2286
+ s42 << r49
2287
+ if r49
2288
+ r50 = _nt_integer
2289
+ s42 << r50
2290
+ if r50
2291
+ r51 = _nt_space
2292
+ s42 << r51
2293
+ if r51
2294
+ r52 = _nt_integer
2295
+ s42 << r52
2296
+ if r52
2297
+ r53 = _nt_space
2298
+ s42 << r53
2299
+ if r53
2300
+ r54 = _nt_host
2301
+ s42 << r54
2302
+ end
2303
+ end
2304
+ end
2305
+ end
2306
+ end
2307
+ end
2308
+ end
2309
+ end
2310
+ end
2311
+ end
2312
+ end
2313
+ if s42.last
2314
+ r42 = instantiate_node(SyntaxNode,input, i42...index, s42)
2315
+ r42.extend(SrvRecord3)
2316
+ else
2317
+ @index = i42
2318
+ r42 = nil
2319
+ end
2320
+ if r42
2321
+ r0 = r42
2322
+ r0.extend(SrvRecord4)
2323
+ else
2324
+ @index = i0
2325
+ r0 = nil
2326
+ end
2327
+ end
2328
+ end
1777
2329
  end
1778
2330
 
1779
2331
  node_cache[:srv_record][start_index] = r0
@@ -2380,7 +2932,7 @@ module DNS
2380
2932
  if r4
2381
2933
  r3 = r4
2382
2934
  else
2383
- if has_terminal?('\G[a-zA-Z0-9\\-)]', true, index)
2935
+ if has_terminal?('\G[+a-zA-Z0-9\\-)]', true, index)
2384
2936
  r5 = true
2385
2937
  @index += 1
2386
2938
  else
@@ -1,5 +1,5 @@
1
1
  module DNS
2
2
  module Zonefile
3
- VERSION = "1.0.3"
3
+ VERSION = "1.0.4"
4
4
  end
5
5
  end
@@ -73,6 +73,19 @@ unquoted TXT some text data
73
73
 
74
74
  45 IN PTR @
75
75
 
76
+
77
+ eam 900 IN SRV 5 0 5269 www
78
+ eam IN 900 SRV 5 0 5269 www
79
+ eam IN SRV 5 0 5269 www
80
+ eam 900 SRV 5 0 5269 www
81
+ eam SRV 5 0 5269 www
82
+
83
+ eam 900 IN CNAME www
84
+ eam IN 900 CNAME www
85
+ eam IN CNAME www
86
+ eam 900 CNAME www
87
+ eam CNAME www
88
+
76
89
  $ORIGIN test.example.com.
77
90
  $TTL 3600; expire in 1 day.
78
91
  @ A 10.1.0.1 ; Test with alternate origin
@@ -114,7 +127,7 @@ ZONE
114
127
 
115
128
  it "should build the correct number of resource records" do
116
129
  zone = DNS::Zonefile.parse(@zonefile)
117
- zone.rr.size.should be(33)
130
+ zone.rr.size.should be(43)
118
131
  end
119
132
 
120
133
  it "should build the correct NS records" do
@@ -188,7 +201,7 @@ ZONE
188
201
  it "should build the correct CNAME records" do
189
202
  zone = DNS::Zonefile.load(@zonefile)
190
203
  cname_records = zone.records_of DNS::Zonefile::CNAME
191
- cname_records.size.should be(3)
204
+ cname_records.size.should be(8)
192
205
 
193
206
  cname_records.detect { |cname|
194
207
  cname.host == "www.example.com." && cname.target == "ns.example.com."
@@ -201,6 +214,18 @@ ZONE
201
214
  cname_records.detect { |cname|
202
215
  cname.host == "www2.example.com." && cname.domainname == "ns.example.com." && cname.ttl == 86400
203
216
  }.should_not be_nil
217
+
218
+ eam_records = cname_records.select { |c| c.host =~ /eam\./ }
219
+
220
+ eam_records.should have(5).records
221
+
222
+ eam_records.each { |cname|
223
+ cname.target.should == "www.example.com."
224
+ }
225
+
226
+ r = eam_records.group_by { |c| c.ttl }
227
+ (r[900] || []).should have(3).records
228
+ (r[86400] || []).should have(2).records
204
229
  end
205
230
 
206
231
  it "should build the correct MX records" do
@@ -260,11 +285,24 @@ ZONE
260
285
  it "should build the correct SRV records" do
261
286
  zone = DNS::Zonefile.load(@zonefile)
262
287
  srv_records = zone.records_of DNS::Zonefile::SRV
263
- srv_records.size.should be(1)
288
+ srv_records.size.should be(6)
264
289
 
265
290
  srv_records.detect { |r|
266
291
  r.host == "_xmpp-server._tcp.example.com." && r.priority == 5 && r.weight == 0 && r.port == 5269 && r.target == 'xmpp-server.l.google.com.' && r.ttl == 86400
267
292
  }.should_not be_nil
293
+
294
+ eam_records = srv_records.select { |s| s.host =~ /eam\./ }
295
+ eam_records.should have(5).records
296
+ eam_records.each { |srv|
297
+ srv.target.should == "www.example.com."
298
+ srv.priority.should == 5
299
+ srv.port.should == 5269
300
+ srv.weight.should == 0
301
+ }
302
+
303
+ r = eam_records.group_by { |c| c.ttl }
304
+ (r[900] || []).should have(3).records
305
+ (r[86400] || []).should have(2).records
268
306
  end
269
307
 
270
308
  it "should build the correct TXT records" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dns-zonefile
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,27 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-23 00:00:00.000000000Z
12
+ date: 2012-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70172232872340 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - =
19
+ - - '='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '2.6'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70172232872340
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: '2.6'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rake
27
- requirement: &70172232871920 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70172232871920
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: treetop
38
- requirement: &70172232871460 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70172232871460
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: polyglot
49
- requirement: &70172232871040 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,11 +69,25 @@ dependencies:
54
69
  version: '0'
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *70172232871040
58
- description: ! "The format of a DNS Zonefile is defined in RFC 1035 section 5 and
59
- RFC\n1034 section 3.6.1. To anyone who's using BIND they'll look very \nfamiliar.\n\nThis
60
- is an attempt to use Ruby parse them into an object graph which can \nbe investigated
61
- programatically, manipulated, validated or printed into \nsome canonical form."
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: ! 'The format of a DNS Zonefile is defined in RFC 1035 section 5 and
79
+ RFC
80
+
81
+ 1034 section 3.6.1. To anyone who''s using BIND they''ll look very
82
+
83
+ familiar.
84
+
85
+
86
+ This is an attempt to use Ruby parse them into an object graph which can
87
+
88
+ be investigated programatically, manipulated, validated or printed into
89
+
90
+ some canonical form.'
62
91
  email:
63
92
  - craig@barkingiguana.com
64
93
  executables: []
@@ -66,10 +95,10 @@ extensions: []
66
95
  extra_rdoc_files: []
67
96
  files:
68
97
  - .gitignore
98
+ - .travis.yml
69
99
  - Gemfile
70
- - Gemfile.lock
71
100
  - LICENCE
72
- - README
101
+ - README.md
73
102
  - Rakefile
74
103
  - TODO
75
104
  - dns-zonefile.gemspec
@@ -95,15 +124,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
124
  - - ! '>='
96
125
  - !ruby/object:Gem::Version
97
126
  version: '0'
127
+ segments:
128
+ - 0
129
+ hash: -1344600706130778289
98
130
  required_rubygems_version: !ruby/object:Gem::Requirement
99
131
  none: false
100
132
  requirements:
101
133
  - - ! '>='
102
134
  - !ruby/object:Gem::Version
103
135
  version: '0'
136
+ segments:
137
+ - 0
138
+ hash: -1344600706130778289
104
139
  requirements: []
105
140
  rubyforge_project: dns-zonefile
106
- rubygems_version: 1.8.10
141
+ rubygems_version: 1.8.24
107
142
  signing_key:
108
143
  specification_version: 3
109
144
  summary: Work with zonefiles (RFC 1035 section 5 and RFC 1034 section 3.6.1)
data/Gemfile.lock DELETED
@@ -1,32 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- dns-zonefile (1.0.2)
5
- polyglot
6
- treetop
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- diff-lcs (1.1.3)
12
- polyglot (0.3.3)
13
- rake (0.9.2.2)
14
- rspec (2.6.0)
15
- rspec-core (~> 2.6.0)
16
- rspec-expectations (~> 2.6.0)
17
- rspec-mocks (~> 2.6.0)
18
- rspec-core (2.6.4)
19
- rspec-expectations (2.6.0)
20
- diff-lcs (~> 1.1.2)
21
- rspec-mocks (2.6.0)
22
- treetop (1.4.10)
23
- polyglot
24
- polyglot (>= 0.3.1)
25
-
26
- PLATFORMS
27
- ruby
28
-
29
- DEPENDENCIES
30
- dns-zonefile!
31
- rake
32
- rspec (= 2.6)