<commit_before>dns-zone
========

A Ruby library for building and parsing DNS zone files.

## Installation

Add this line to your Gemfile:

    gem 'dns-zone'

And then execute:

    bundle install

Require the gem in your code:

    require 'dns/zone'

## Usage

    DNS::Zone.new
    DNS::Zone.load(zone_as_string)
    DNS::Zone::RR.load(rr_as_string)
    DNS::Zone::RR::A.load(a_rr_as_string)

    zone = DNS::Zone.new
    zone.origin = 'example.com.'
    # FIXME: not sure what RFC (if any) defines the time formatting
    zone.ttl = '1d'
    # FIXME: keep DNS style representation? for <domain-name>s and email addresses
    zone.soa.nameserver = 'ns0.lividpenguin.com.'
    zone.soa.email = 'hostmaster.lividpenguin.com.'

    # output as dns zone file
    zone.to_zone_file

## Development Commands

    # install external gem dependencies first
    bundle install

    # run all tests and build code coverage
    bundle exec rake test

    # hints where to improve docs
    bundle exec inch

    # watch for changes and run development commands (tests, documentation, etc)
    bundle exec guard

## Notes

- RR Format: `[<TTL>] [<class>] <type> <RDATA>`
- A DNS zone is built from RR's and a couple of other special statements.
- [RFC 1035 - Domain Names - Implementation and Specification](http://www.ietf.org/rfc/rfc1035.txt)<commit_msg>Create a little todo list and add some extra notes<commit_after>dns-zone
========

A Ruby library for building and parsing DNS zone files.

## Installation

Add this line to your Gemfile:

    gem 'dns-zone'

And then execute:

    bundle install

Require the gem in your code:

    require 'dns/zone'

## Usage

    DNS::Zone.new
    DNS::Zone.load(zone_as_string)
    DNS::Zone::RR.load(rr_as_string)
    DNS::Zone::RR::A.load(a_rr_as_string)

    zone = DNS::Zone.new
    zone.origin = 'example.com.'
    # FIXME: not sure what RFC (if any) defines the time formatting
    zone.ttl = '1d'
    # FIXME: keep DNS style representation? for <domain-name>s and email addresses
    zone.soa.nameserver = 'ns0.lividpenguin.com.'
    zone.soa.email = 'hostmaster.lividpenguin.com.'

    # output as dns zone file
    zone.to_zone_file


# Development

## Development Commands

    # install external gem dependencies first
    bundle install

    # run all tests and build code coverage
    bundle exec rake test

    # hints where to improve docs
    bundle exec inch

    # watch for changes and run development commands (tests, documentation, etc)
    bundle exec guard

# TODO

## Must have

    [ ] Ability to load a whole zone
    [ ] Add support for RR Type: SOA
    [ ] Add support for RR Type: PTR
    [ ] Add support for RR Type: SPF
    [ ] Add support for RR Type: LOC
    [ ] Add support for RR Type: HINFO

## Would be nice

    [ ] Handle parsing a zone file that uses more then one $ORIGIN statement.
    [ ] Validation, error checking...
        [ ] Only one SOA per zone.
        [ ] CNAMEs can't use a label of `@`.

    [ ] Ability to 'include' defaults/records into a zone.
        This may or may not want to mean supporting the `$INCLUDE` statement.

## At some point; low priority

    [ ] Configuration options:
        [ ] spaces/tabs used between RR params in zone file output
        [ ] time format to use (seconds or bind time format (e.g. 1d))
        [ ] add comments to explain TTL's that are in seconds
    [ ] Ability to add comment to RR (n.b. currently we strip comments when parsing)
    [ ] Add support for RR Type: DNAME
    [ ] Add support for RR Type: DNSKEY
    [ ] Add support for RR Type: DS
    [ ] Add support for RR Type: KEY
    [ ] Add support for RR Type: NSEC
    [ ] Add support for RR Type: RRSIG
    [ ] Add support for RR Type: NAPTR
    [ ] Add support for RR Type: RP
    [ ] Add support for RR Type: RT

# Notes

- RR Format: `[<TTL>] [<class>] <type> <RDATA>`
- A DNS zone is built from RR's and a couple of other special statements.
- If zone file does not include $ORIGIN, it will be inferred by the `zone "<zone-name>" {}` clause from bind.conf
  In general we should always explicitly define an $ORIGIN directive unless there is a very good reason not to.
- [RFC 1035 - Domain Names - Implementation and Specification](http://www.ietf.org/rfc/rfc1035.txt)
{'fraction_non_alphanumeric': 0.0929359305327388, 'fraction_numerical': 0.00492842055855433, 'mean_word_length': 2.910091743119266, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2509911', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1291, 'n_words': 524}