View definition

func ParseZone

Defined in


ParseZone reads a RFC 1035 style zonefile from r. It returns *Tokens on the returned channel, which consist out the parsed RR, a potential comment or an error. If there is an error the RR is nil. The string file is only used in error reporting. The string origin is used as the initial origin, as if the file would start with: $ORIGIN origin . The directives $INCLUDE, $ORIGIN, $TTL and $GENERATE are supported. The channel t is closed by ParseZone when the end of r is reached.

Basic usage pattern when reading from a string (z) containing the zone data:

	for x := range dns.ParseZone(strings.NewReader(z), "", "") {
		if x.Error != nil {
                 // log.Println(x.Error)
             } else {
                 // Do something with x.RR

Comments specified after an RR (and on the same line!) are returned too:

foo. IN A ; this is a comment

The text "; this is comment" is returned in Token.Comment. Comments inside the RR are discarded. Comments on a line by themselves are discarded too.

ParseZone is referenced in 7 repositories