gozone

package module
v0.0.0-...-2b0ae8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2020 License: MIT Imports: 9 Imported by: 0

README

Simple DNS ZoneFile parser

Parse a DNS ZoneFile (as specified in https://www.ietf.org/rfc/rfc1035.txt) into a series of more-easily-processed "Record" structures.

The list of RecordTypes, their values, and meanings, was taken from https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml, which in turn references RFCs:

Example:

stream, _ := os.Open(zonefile)
var record gozone.Record
scanner := gozone.NewScanner(h)

for {
	err := scanner.Next(&record)
	if err != nil {
		break
	}

	fmt.Printf("a '%s' Record for domain/subdomain '%s'",
		record.Type,
		record.DomainName,
	)
}

Documentation

Index

Constants

View Source
const (
	RecordClass_UNKNOWN = 0   // unset
	RecordClass_IN      = 1   // the Internet
	RecordClass_CS      = 2   // the CSNET class (Obsolete - used only for examples in some obsolete RFCs)
	RecordClass_CH      = 3   // the CHAOS class
	RecordClass_HS      = 4   // Hesiod [Dyer 87]
	RecordClass_any     = 255 // any class (spelled: *; appears only in the question section of a query; included for completeness)
)
View Source
const (
	RecordType_UNKNOWN    = 0  // unset
	RecordType_A          = 1  // a host address
	RecordType_NS         = 2  // an authoritative name server
	RecordType_MD         = 3  // a mail destination (OBSOLETE - use MX)
	RecordType_MF         = 4  // a mail forwarder (OBSOLETE - use MX)
	RecordType_CNAME      = 5  // the canonical name for an alias
	RecordType_SOA        = 6  // marks the start of a zone of authority
	RecordType_MB         = 7  // a mailbox domain name (EXPERIMENTAL)
	RecordType_MG         = 8  // a mail group member (EXPERIMENTAL)
	RecordType_MR         = 9  // a mail rename domain name (EXPERIMENTAL)
	RecordType_NULL       = 10 // a null RR (EXPERIMENTAL)
	RecordType_WKS        = 11 // a well known service description
	RecordType_PTR        = 12 // a domain name pointer
	RecordType_HINFO      = 13 // host information
	RecordType_MINFO      = 14 // mailbox or mail list information
	RecordType_MX         = 15 // mail exchange
	RecordType_TXT        = 16 // text strings
	RecordType_RP         = 17 // for Responsible Person
	RecordType_AFSDB      = 18 // for AFS Data Base location
	RecordType_X25        = 19 // for X.25 PSDN address
	RecordType_ISDN       = 20 // for ISDN address
	RecordType_RT         = 21 // for Route Through
	RecordType_NSAP       = 22 // for NSAP address, NSAP style A record
	RecordType_NSAP_PTR   = 23 // spelled "NSAP-PTR", for domain name pointer, NSAP style
	RecordType_SIG        = 24 // for security signature
	RecordType_KEY        = 25 // for security key
	RecordType_PX         = 26 // X.400 mail mapping information
	RecordType_GPOS       = 27 // Geographical Position
	RecordType_AAAA       = 28 // IP6 Address
	RecordType_LOC        = 29 // Location Information
	RecordType_NXT        = 30 // Next Domain (OBSOLETE)
	RecordType_EID        = 31 // Endpoint Identifier
	RecordType_NIMLOC     = 32 // Nimrod Locator
	RecordType_SRV        = 33 // Server Selection
	RecordType_ATMA       = 34 // ATM Address
	RecordType_NAPTR      = 35 // Naming Authority Pointer
	RecordType_KX         = 36 // Key Exchanger
	RecordType_CERT       = 37 // CERT
	RecordType_A6         = 38 // A6 (OBSOLETE - use AAAA)
	RecordType_DNAME      = 39 // DNAME
	RecordType_SINK       = 40 // SINK
	RecordType_OPT        = 41 // OPT
	RecordType_APL        = 42 // APL
	RecordType_DS         = 43 // Delegation Signer
	RecordType_SSHFP      = 44 // SSH Key Fingerprint
	RecordType_IPSECKEY   = 45 // IPSECKEY
	RecordType_RRSIG      = 46 // RRSIG
	RecordType_NSEC       = 47 // NSEC
	RecordType_DNSKEY     = 48 // DNSKEY
	RecordType_DHCID      = 49 // DHCID
	RecordType_NSEC3      = 50 // NSEC3
	RecordType_NSEC3PARAM = 51 // NSEC3PARAM
	RecordType_TLSA       = 52 // TLSA
	RecordType_SMIMEA     = 53 // S/MIME cert association
	// Unassigned 54
	RecordType_HIP        = 55 // Host Identity Protocol
	RecordType_NINFO      = 56 // NINFO
	RecordType_RKEY       = 57 // RKEY
	RecordType_TALINK     = 58 // Trust Anchor LINK
	RecordType_CDS        = 59 // Child DS
	RecordType_CDNSKEY    = 60 // DNSKEY(s) the Child wants reflected in DS
	RecordType_OPENPGPKEY = 61 // OpenPGP Key
	RecordType_CSYNC      = 62 // Child-To-Parent Synchronization
	RecordType_ZONEMD     = 63 // message digest for DNS zone
	// Unassigned	64-98
	RecordType_SPF    = 99  // declares which hosts are, and are not, authorized to use a domain name for the "HELO" and "MAIL FROM" identities (OBSOLETE - use TXT)
	RecordType_UINFO  = 100 // [IANA-Reserved]
	RecordType_UID    = 101 // [IANA-Reserved]
	RecordType_GID    = 102 // [IANA-Reserved]
	RecordType_UNSPEC = 103 // [IANA-Reserved]
	RecordType_NID    = 104 // values for Node Identifiers that will be used for ILNP-capable nodes
	RecordType_L32    = 105 // 32-bit Locator values for ILNPv4-capable nodes
	RecordType_L64    = 106 // unsigned 64-bit Locator values for ILNPv6-capable nodes
	RecordType_LP     = 107 // the name of a subnetwork for ILNP
	RecordType_EUI48  = 108 // an EUI-48 address
	RecordType_EUI64  = 109 // an EUI-64 address
	// Unassigned 110-248
	RecordType_TKEY     = 249 // Transaction Key
	RecordType_TSIG     = 250 // Transaction Signature
	RecordType_IXFR     = 251 // incremental transfer
	RecordType_AXFR     = 252 // transfer of an entire zone
	RecordType_MAILB    = 253 // mailbox-related RRs (MB, MG or MR)
	RecordType_MAILA    = 254 // mail agent RRs (OBSOLETE - see MX)
	RecordType_all      = 255 // Spelled "*", A request for some or all records the server has available
	RecordType_URI      = 256 // URI
	RecordType_CAA      = 257 // Certification Authority Restriction
	RecordType_AVC      = 258 // Application Visibility and Control
	RecordType_DOA      = 259 // Digital Object Architecture
	RecordType_AMTRELAY = 260 // Automatic Multicast Tunneling Relay
	// Unassigned	261-32767
	RecordType_TA  = 32768 // DNSSEC Trust Authorities
	RecordType_DLV = 32769 // DNSSEC Lookaside Validation
	// Unassigned	32770-65279
	// Private use	65280-65534
	RecordType_type65534 = 65534 // used in signing

)

Variables

This section is empty.

Functions

This section is empty.

Types

type Record

type Record struct {
	DomainName string
	TimeToLive int64 // uint32, expanded and signed to allow for "unset" indicator
	Class      RecordClass
	Type       RecordType
	Data       []string
	Comment    string
}

func (Record) String

func (r Record) String() string

type RecordClass

type RecordClass int

func (RecordClass) String

func (rc RecordClass) String() string

type RecordType

type RecordType int

func (RecordType) String

func (rt RecordType) String() string

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

func NewScanner

func NewScanner(src io.Reader) *Scanner

func (*Scanner) Next

func (s *Scanner) Next(outrecord *Record) error

func (*Scanner) SetOrigin

func (s *Scanner) SetOrigin(domain string) error

func (*Scanner) SetTimeToLive

func (s *Scanner) SetTimeToLive(timeToLive int64) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL