Documentation ¶
Overview ¶
Package dns collects some DNS common stuff.
Index ¶
- Variables
- func DefaultLocalNameServer() net.IP
- func Host2domain(hostname string) (domainname string)
- func IsRooted(name string) bool
- func Labels(name string) (labels []string, err error)
- func MatchCount(namea, nameb string) (n int, err error)
- func RevLookupName(ip net.IP) string
- func RootedName(name string) string
- func Seconds2String(epochSecs int64) string
- func String2Seconds(s string) (secs int64, err error)
- type CharString
- type DomainName
- type GoTree
- func (t *GoTree) Add(owner string, data interface{}, updater func(interface{}) interface{})
- func (t *GoTree) Delete(owner string)
- func (t *GoTree) Enum(root string, handler func(path []string, data interface{}) bool)
- func (t *GoTree) Get(owner string) interface{}
- func (t *GoTree) Match(owner string) interface{}
- func (t *GoTree) Put(owner string, data interface{})
- type LogLevel
- type Logger
- type Octet
- type Octets2
- type Octets4
- type Tree
- func (t *Tree) Add(owner string, data interface{}, updater func(interface{}) interface{})
- func (t *Tree) Delete(owner string)
- func (t *Tree) Enum(root string, handler func(path []string, data interface{}) bool)
- func (t *Tree) Get(owner string) interface{}
- func (t *Tree) Match(owner string) interface{}
- func (t *Tree) Put(owner string, data interface{})
- type WireDecodeSniffed
- type WireDecodeSniffer
- type Wirebuf
- type Wirer
Constants ¶
This section is empty.
Variables ¶
var NoLogger = &Logger{log.New(devNull{}, "", 0), 0}
NoLogger doesn't log anything.
Functions ¶
func DefaultLocalNameServer ¶
DefaultLocalNameServer return the IP of the default local DNS server
func Host2domain ¶
func MatchCount ¶
MatchCount returns the number of labels that namea and nameb have in common or an Error if any. The counting starts at the root label, so any two valid rooted domain names have match count at least one == the root domain.
func RevLookupName ¶
RevLookupName returns a domain name for the DNS reverse lookup or "" if ip is not a valid IP address.
func Seconds2String ¶
Seconds2String converts epoch seconds to a string with the YYYYMMDDHHmmSS format.
func String2Seconds ¶
String2Seconds converts s to epoch seconds. Input string s must be in the YYYYMMDDHHmmSS format or a plain unsigned decadic number < 2^32.
Types ¶
type CharString ¶
type CharString string
CharString is a DNS <character-string> (RFC 1035) implementing Wirer.
func (*CharString) Decode ¶
func (s *CharString) Decode(b []byte, pos *int, sniffer WireDecodeSniffer) (err error)
Implementation of Wirer
func (CharString) Quoted ¶
func (s CharString) Quoted() string
Quoted returns s with `"` escaped as `\"`
type DomainName ¶
type DomainName string
DomainName is a DNS <domain-name> (RFC 1035) implementing Wirer.
func (*DomainName) Decode ¶
func (s *DomainName) Decode(b []byte, pos *int, sniffer WireDecodeSniffer) (err error)
Implementation of Wirer
type GoTree ¶
type GoTree struct {
// contains filtered or unexported fields
}
GoTree is a concurrent access safe version of Tree.
func (*GoTree) Add ¶
Add will add data to GoTree. If the owner node has no data yet, the data will be simply inserted in that node. If the updater is not nil and the owner node already has some existing data then the value returned by updater(existing_data) is inserted into the owner node.
func (*GoTree) Enum ¶
Enum enumerates all data in the tree starting at root and all of its childs. On every datum found the handler is invoked. If the handler returns false the tree traversing stops.
type Logger ¶
The Logger type supports simple/simplified logging based on a log.Logger and dns.LogLevel.
type Octet ¶
type Octet byte
Octet is a byte implementing Wirer.
type Octets2 ¶
type Octets2 uint16
Octets2 is an uint16 implementing Wirer.
type Octets4 ¶
type Octets4 uint32
Octets4 is an uint32 implementing Wirer.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree implements a hierarchical tree of any data (interface{}). The hierarchy is based on case insensitive labels of a rooted domain name. Tree is *not* concurrent access safe.
func (*Tree) Add ¶
Add will add data to Tree. If the owner node has no data yet, the data will be simply inserted in that node. If the updater is not nil and the owner node already has some existing data then the value returned by updater(existing_data) is inserted into the owner node.
func (*Tree) Enum ¶
Enum enumerates all data in the tree starting at root and all of its childs. On every datum found the handler is invoked. If the handler returns false the tree traversing stops.
func (*Tree) Match ¶
Match returns the data associated with the largest part of owner or nil if there are none.
If the tree "map" contains
"www.example.com.": "www-example-com" "example.org.": "www-example-org"
then
t.Match(".") == nil t.Match("com.") == nil t.Match("example.com.") == nil t.Match("www.example.com.") == "www-example-com" t.Match("ns.www.example.com.") == "www-example-com" t.Match("org.") == nil t.Match("example.org.") == "www-example-org" t.Match("www.example.org.") == "www-example-org"
In other words, Match returns the most recent (last seen) data item present in the tree when walking the DNS name hiearchy.
type WireDecodeSniffed ¶
type WireDecodeSniffed int
WireDecodeSniffed tags data passed to WireDecodeSniffer
const ( SniffCharString WireDecodeSniffed // A domain name label SniffClass // A CLASS SniffDomainName // A domain name SniffEXT_RCODE // An EXT_RCODE SniffHeader // A DNS message header SniffIPV4 // An IP V4 address SniffIPV6 // An IP V6 address SniffMessage // A DNS message SniffOPT_DATA // OPT resource record attr/value pair SniffOctet // An octet SniffOctets2 // Two octets SniffOctets4 // Four octets SniffQuestion // A DNS message question SniffQuestionItem // A DNS message question item SniffRData // Resource record data SniffRDataA // A resource record data SniffRDataAAAA // AAAA resource record data SniffRDataAFSDB // AFSDB resource record data SniffRDataCERT // CERT resource record data SniffRDataCNAME // CNAME resource record data SniffRDataDHCID // DHCID resource record data SniffRDataDLV // DLV resource record data SniffRDataDNAME // DNAME resource record data SniffRDataDNSKEY // DNSKEY resource record data SniffRDataDS // DS resource record data SniffRDataGPOS // GPOS resource record data SniffRDataHINFO // HINFO resource record data SniffRDataHIP // HIP resource record data SniffRDataIPSECKEY // IPSECKEY resource record data SniffRDataISDN // ISDN resource record data SniffRDataKEY // KEY resource record data SniffRDataKX // KX resource record data SniffRDataLOC // LOC resource record data SniffRDataMB // MB resource record data SniffRDataMD // MD resource record data SniffRDataMF // MF resource record data SniffRDataMG // MG resource record data SniffRDataMINFO // MINFO resource record data SniffRDataMR // MR resource record data SniffRDataMX // MX resource record data SniffRDataNAPTR // NAPTR pseudo resource record data SniffRDataNODATA // NODATA pseudo resource record data SniffRDataNS // NS resource record data SniffRDataNSAP // NSAP resource record data SniffRDataNSAP_PTR // NSAP-PTR resource record data SniffRDataNSEC // NSEC resource record data SniffRDataNSEC3 // NSEC3 resource record data SniffRDataNSEC3PARAM // NSEC3PARAM resource record data SniffRDataNULL // NULL resource record data SniffRDataOPT // OPT resource record data SniffRDataPTR // PTR resource record data SniffRDataPX // PX resource record data SniffRDataRT // RT resource record data SniffRDataRP // RP resource record data SniffRDataRRSIG // RRSIG resource record data SniffRDataSIG // SIG resource record data SniffRDataSOA // SOA resource record data SniffRDataSPF // SPF resource record data SniffRDataSRV // SRV resource record data SniffRDataSSHFP // SSHFP resource record data SniffRDataTA // TA resource record data SniffRDataTALINK // TALINK resource record data SniffRDataTKEY // TKEY resource record data SniffRDataTLSA // TLSA resource record data SniffRDataTSIG // TSIG resource record data SniffRDataTXT // TXT resource record data SniffRDataURI // URI resource record data SniffRDataWKS // WKS resource record data SniffRDataX25 // X25 resource record data SniffRR // Any or unknown/unsupported type resource record SniffType // A TYPE )
Values of WireDecodeSniffed
type WireDecodeSniffer ¶
type WireDecodeSniffer func(p0, p *byte, tag WireDecodeSniffed, info interface{})
WireDecodeSniffer is the type of the hook called by Wirer.Decode. p0 points to a wire buffer on entry to Decode, p to the last byte of the buffer used on leaving the same. tag describes what was pulled from the wire buffer and info may optionally carry the just decoded entity (or a pointer to the same when more ćonvenient).
type Wirebuf ¶
type Wirebuf struct { Buf []byte // The encoding buffer // contains filtered or unexported fields }
Wirebuf holds data for encoding DNS messages.
func NewWirebuf ¶
func NewWirebuf() *Wirebuf
NewWirebuf returns a newly created Wirebuf ready for use. Compression is enabled by default.
func (*Wirebuf) DisableCompression ¶
func (w *Wirebuf) DisableCompression()
DisableCompression decrements enable of <domain-name> compression (RFC 1034/4.1.4)
func (*Wirebuf) EnableCompression ¶
func (w *Wirebuf) EnableCompression()
EnableCompression increments enable of <domain-name> compression (RFC 1034/4.1.4)
type Wirer ¶
type Wirer interface { // Encode appends data in DNS wire format to Wirebuf.Buf. // If the buffer has not enough free space available it will be reallocated. Encode(*Wirebuf) // Decode decodes data from a DNS wire format in b, starting at p. // Decode may return a non nil Error if b is not in the correct format. // After Decode, p is adjusted to reflect the amount of data consumed from b. // If sniffer is not nil it is invoked with a description of the decoded stuff. Decode(b []byte, p *int, sniffer WireDecodeSniffer) error }
Wirer is a DNS wire format encoder/decoder.
Directories ¶
Path | Synopsis |
---|---|
Package cache supports caching of DNS resource records.
|
Package cache supports caching of DNS resource records. |
Package hosts supports hosts formatted data (see also `man hosts`).
|
Package hosts supports hosts formatted data (see also `man hosts`). |
Package msg handles DNS messages.
|
Package msg handles DNS messages. |
WIP: Package named supports named.conf formatted data (see also `man named.conf`).
|
WIP: Package named supports named.conf formatted data (see also `man named.conf`). |
Package pcat supports reading files produced by the pcat utility which is a part of the NLnet Labs' ldns project.
|
Package pcat supports reading files produced by the pcat utility which is a part of the NLnet Labs' ldns project. |
Package resolv supports resolv.conf formatted data (see also `man resolv.conf`).
|
Package resolv supports resolv.conf formatted data (see also `man resolv.conf`). |
Package resolver is a simple DNS resolver.
|
Package resolver is a simple DNS resolver. |
Package rr supports DNS resource records (RFC 1035 chapter 3.2).
|
Package rr supports DNS resource records (RFC 1035 chapter 3.2). |
Package xfr supports DNS zone transfers.
|
Package xfr supports DNS zone transfers. |
WIP: Package zdb provides a specialized DB engine for DNS zone(s)/a DNS server, i.e.
|
WIP: Package zdb provides a specialized DB engine for DNS zone(s)/a DNS server, i.e. |
Package zone handles master files which may be textual data formated as per RFC 1035 chapter 5 or binary data produced by Compiler.
|
Package zone handles master files which may be textual data formated as per RFC 1035 chapter 5 or binary data produced by Compiler. |