Skip to content

Commit

Permalink
Allow reordering ot class and TTL for TXT records
Browse files Browse the repository at this point in the history
  • Loading branch information
aeden committed Nov 24, 2022
1 parent bef1b5c commit ed72160
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/dns/zonefile.treetop
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ grammar Zonefile
end

rule txt_record
host space ms_age ttl klass "TXT" space data:ms_txt_data {
(
host space ms_age ttl klass "TXT" space data:ms_txt_data /
host space ms_age klass ttl "TXT" space data:ms_txt_data
) {
def to_s
"#{host} #{ttl} #{klass} TXT #{data}"
end
Expand Down
9 changes: 7 additions & 2 deletions spec/dns/zonefile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
with LF and CRLF line endings"
with-underscore TXT abc_123
with-ttl 60 TXT "example"
with-class IN TXT "example"
ttl-class 60 IN TXT "example"
class-ttl IN 60 TXT "example"
@ CAA 0 issue "letsencrypt.org"
issuewild CAA 0 issuewild "comodoca.com"
Expand Down Expand Up @@ -183,7 +188,7 @@

it "should build the correct number of resource records" do
zone = DNS::Zonefile.parse(@zonefile)
expect(zone.rr.size).to eq(88)
expect(zone.rr.size).to eq(92)
end

it "should build the correct NS records" do
Expand Down Expand Up @@ -408,7 +413,7 @@
it "should build the correct TXT records" do
zone = DNS::Zonefile.load(@zonefile)
txt_records = zone.records_of DNS::Zonefile::TXT
expect(txt_records.size).to eq(8)
expect(txt_records.size).to eq(12)

expect(txt_records.detect { |r|
r.host == "_domainkey.example.com." && r.data == '"v=DKIM1\;g=*\;k=rsa\; p=4tkw1bbkfa0ahfjgnbewr2ttkvahvfmfizowl9s4g0h28io76ndow25snl9iumpcv0jwxr2k"'
Expand Down

0 comments on commit ed72160

Please sign in to comment.