lantins / dns-zone

A Ruby library for building and parsing DNS zone files.
MIT License
22 stars 13 forks source link

Zone files with multiple $ORIGINs produce incorrect labels #11

Open SamLR opened 7 years ago

SamLR commented 7 years ago

Zone files with more than one $ORIGIN will produce incorrect (repeating) labels for records with later $ORIGINs that don't explicitly set their name to either '@' or some other name.

For example:

$ORIGIN example.com.
@   3600    SOA     ns1.example.com. (
                        hostmaster.example.com.
                        42
                        3600
                        600
                        86400
                        300
                        )

$ORIGIN sub.example.com.
@   3600    CNAME   sub2.example.com.
    3600    MX      10 mail.example.com.

will produce:

> zone = DNS::Zone::load(File.read('test.zone'))
> zone.records.each{ |r| puts r.label }
  @
  sub
  sub.sub

where the third label should be 'sub'.

hron84 commented 3 years ago

My example is bit more weird:

$ORIGIN domain.com.
test A 1.2.3.4

results the record will be test.domaincom. Which is pretty not what I need.