mschilli/dns-zoneparse-perl — pull request #2 by xdrr (2014-10-20 05:11:45+00:00)
Title: Add $INCLUDE parsing and RFC 2308 $TTL compliance

This pull request contains both the $INCLUDE parsing functionality and RFC 2308 $TTL complaince changes into the dns-zoneparse-perl repo (both of which are explained below).

$INCLUDE parsing

$INCLUDE directives are read and parsed before the main record parsing loop to enable the included records to be parsed in the same manner as all other records.

The domain and comment parameters are supported by this new functionality however the latter is not used in the code. The domain parameter sets the relative origin of the records that are included. If excluded, the origin of the including zone is used.

The behavior of the $INCLUDE directive is to include the records of the zone file specified at the position of the directive, meaning that if the first record in the included zone has a blank name it will inherit the name of the last named record, as expected in any zone.

Added new test 'dns-zoneparse-include.t' to test the inclusion of records from another zone but without impacting the primary test. The new test is mostly a clone of dns-zoneparse.t however testing of the parsing of previously parsed and outputted records is not performed as this returns the included records being returned in an order different than when parsed directly from file or variable.

The addition of the test also saw the addition of 2 new zones, 'include-test-zone.db' which contains the $INCLUDE directives and 'included-test-zone.db' which is included by the former zone and has slight alternations in the record name and or values to distinguish the records in the test.

RFC2308 $TTL compliance

The RFC above introduces the $TTL directive that when configured causes all RRs to have their TTL set to the $TTL value if not explicitly set. This overrides the behavior of records inheriting the TTL from the last record that had it explicitly set.

The $dns_dollar_ttl variable has been introduced to store the TTL value when set by the directive and used to set the TTL of records when one is not already defined by the record.

When the $TTL directive is not used, records will use the original behavior of inheriting the last explicitly set TTL value or using the SOA record's minimum TTL.

An additional test 'dns-zoneparse-dollar-ttl.t' has been added to prove that the original behavior works when the $TTL directive is not set. The master test 'dns-zoneparse.t' has been updated to reflect the parsed result when the $TTL directive is set.