Documentation
¶
Overview ¶
Package dns provides a fine grained DNS message parsing and building library
Index ¶
- Constants
- Variables
- func BuildName(name string, domains *Domains) string
- func ParseName(buf *bytes.Buffer, ptr int, domains *Domains) (string, error)
- type CName
- type Class
- type Domains
- type IPv4
- type IPv6
- type Message
- type Opt
- type Ptr
- type Question
- type RData
- type Record
- type Srv
- type Txt
- type Type
Constants ¶
const ( // OptRa describes if recursion is available OptRa = 0x80 // OptRd describes if recursion is desired OptRd = 0x100 // OptTc describes if the messages was truncated OptTc = 0x200 // OptAa describes weither a response came from the authoritative server OptAa = 0x400 // OptQr describes if the message is a query (0) or response (1) OptQr = 0x8000 )
const ( // NamePointer indication byte NamePointer = 0xc0 // PointerMask is the reverse of the indication byte for 16 bits PointerMask = 0x3fff )
const CacheFlushBit = 0x8000
CacheFlushBit holds the bit for the mDNS cache flush instruction
const HdrLength = 12
HdrLength is the length of a DNS message header
const UnicastResponseBit = 0x8000
UnicastResponseBit holds the bit for the mDNS unicast response
Variables ¶
var RRTypeStrings = map[Type]string{ A: "A", NS: "NS", CNAME: "CNAME", SOA: "SOA", PTR: "PTR", HINFO: "HINFO", MX: "MX", TXT: "TXT", RP: "RP", AFSDB: "AFSDB", SIG: "SIG", KEY: "KEY", AAAA: "AAAA", LOC: "LOC", SRV: "SRV", NAPTR: "NAPTR", KX: "KX", CERT: "CERT", DNAME: "DNAME", OPT: "OPT", APL: "APL", DS: "DS", SSHFP: "SSHFP", IPSECKEY: "IPSECKEY", RRSIG: "RRSIG", NSEC: "NSEC", DNSKEY: "DNSKEY", DHCID: "DHCID", NSEC3: "NSEC3", NSEC3PARAM: "NSEC3PARAM", TLSA: "TLSA", SMIMEA: "SMIMEA", HIP: "HIP", CDS: "CDS", CDNSKEY: "CDNSKEY", OPENPGPKEY: "OPENPGPKEY", CSYNC: "CSYNC", ZONEMD: "ZONEMD", SVCB: "SVCB", HTTPS: "HTTPS", EUI48: "EUI48", EUI64: "EUI64", TKEY: "TKEY", TSIG: "TSIG", IXFR: "IXFR", AXFR: "AXFR", URI: "URI", CAA: "CAA", TA: "TA", DLV: "DLV", }
RRTypeStrings holds name mapping for DNS type constants
Functions ¶
Types ¶
type CName ¶
type CName struct { Name string // contains filtered or unexported fields }
CName implements interface RData
func (*CName) TransformName ¶
TransformName satisfies the interface
type Class ¶
type Class uint16
Class is just a uint16
const ( // IN is the standard class IN Class = 1 )
type Domains ¶
type Domains struct {
// contains filtered or unexported fields
}
Domains holds maps for parsing and building CNAME pointers
type IPv4 ¶
IPv4 implements interface RData
func (*IPv4) TransformName ¶
TransformName satisfies the interface
type IPv6 ¶
IPv6 implements interface RData
func (*IPv6) TransformName ¶
TransformName satisfies the interface
type Message ¶
type Message struct { ID uint16 QR bool OPCode uint8 AA bool TC bool RD bool RA bool RCode uint8 Questions []Question Answers []Record Nameservers []Record Additional []Record // contains filtered or unexported fields }
Message is the structure of an entire DNS message including subtypes
func ParseMessage ¶
ParseMessage creates a new Message containing parsed DNS information from buf
func (*Message) BuildHeader ¶
BuildHeader writes DNS header to buf
type Opt ¶
type Opt struct { UDPSize uint16 RCode byte EDNSVersion byte DNSSec bool Record *Record Options map[uint16][]byte }
Opt implements interface for RDATA
func (*Opt) TransformName ¶
TransformName satisfies the interface
type Ptr ¶
type Ptr struct { Name string // contains filtered or unexported fields }
Ptr implements interface RData
func (*Ptr) TransformName ¶
TransformName satisfies the interface
type Question ¶
Question holds single dns questions
func ParseQuestion ¶
ParseQuestion parses DNS question records
type RData ¶
type RData interface { Parse(*bytes.Buffer, int, *Domains) error Build(*bytes.Buffer, *Domains) error PreBuild(*Record, *Domains) (int, error) TransformName(string) string }
RData interface for all record types
type Record ¶
type Record struct { TTL uint32 Class uint16 Length uint16 Type Type Name string Data RData CacheFlush bool }
Record struct used by record specific types
func ParseRecord ¶
ParseRecord is the generic entry to parsing all records
type Srv ¶
type Srv struct { Priority uint16 Weight uint16 Port uint16 Target string NameBytes string // It seems like a lot of services does things like // [identifier]._[service]._[proto].[name] // Support this scheme by adding data to this field if it there's more parts // to be parsed from the name Identifier string Service string Proto string Name string // contains filtered or unexported fields }
Srv implements interface RData
func (*Srv) TransformName ¶
TransformName adds service/proto/name fields of server record
type Txt ¶
Txt implements interface RData
func (*Txt) TransformName ¶
TransformName adds service/proto/name fields of server record
type Type ¶
type Type uint16
Type is just a uint16
const ( A Type = 1 NS Type = 2 CNAME Type = 5 SOA Type = 6 PTR Type = 12 HINFO Type = 13 MX Type = 15 TXT Type = 16 RP Type = 17 AFSDB Type = 18 SIG Type = 24 KEY Type = 25 AAAA Type = 28 LOC Type = 29 SRV Type = 33 NAPTR Type = 35 KX Type = 36 CERT Type = 37 DNAME Type = 39 OPT Type = 41 APL Type = 42 DS Type = 43 SSHFP Type = 44 IPSECKEY Type = 45 RRSIG Type = 46 NSEC Type = 47 DNSKEY Type = 48 DHCID Type = 49 NSEC3 Type = 50 NSEC3PARAM Type = 51 TLSA Type = 52 SMIMEA Type = 53 HIP Type = 55 CDS Type = 59 CDNSKEY Type = 60 OPENPGPKEY Type = 61 CSYNC Type = 62 ZONEMD Type = 63 SVCB Type = 64 HTTPS Type = 65 EUI48 Type = 108 EUI64 Type = 109 TKEY Type = 249 TSIG Type = 250 IXFR Type = 251 AXFR Type = 252 URI Type = 256 CAA Type = 257 TA Type = 32768 DLV Type = 32769 )
List of all DNS type constants