Categorygithub.com/jsumners/go-zone
modulepackage
1.0.1
Repository: https://github.com/jsumners/go-zone.git
Documentation: pkg.go.dev

# README

go-zone

This library provides methods for parsing DNS zone (master) files as described in RFC 1035 §5.1. A more comprehensive parser is available in https://pkg.go.dev/github.com/miekg/dns#ZoneParser. The parser in this library will parse files that contain "loose" records whereas the miekg parser strictly requires an origin to be defined.

This library was written to support gdns, a REST API client for the Gandi LiveDNS service, which needs to read individual records from zone-like files so that they can be used to provide values to the remote API.

Example

package main

import (
	"fmt"
	"strings"
	"github.com/jsumners/go-zone"
)

func main() {
	zoneData := "foo 300 in a 1.2.3.4\n"
	zp, _ := zone.NewZoneParser()
	z, _ := zp.Parse(strings.NewReader(zoneData))

	fmt.Println(z)
}

Note On Looseness

Consider the record line:

a in ns

The line is meant to define a nameserver record for the server a. But it is missing the value. Whereas a strict parser will refuse to parse this line, this library will return a ResourceRecord with an empty values list:

ResourceRecord {
	Name: "a",
	Class: "in",
	Type: "ns",
	Values: []string{},
}

For a more complete understanding of the consequences of the looseness of the parser, review the testdata/bind9 fixtures and their expected results. The expectations do not always conform to what Bind would allow. There are further details in the included Readme.

RFCs

# Functions

No description provided by the author
WithDefaultTtl allows defining the default TTL that will be used when no $TTL directive has been found.
WithPreferSoaMinTtl will _always_ use the minimum TTL value from the SOA line when value is `true`.
No description provided by the author

# Variables

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
ZoneParser reads zone [master files] into [Zone] objects.

# Type aliases

No description provided by the author