dnsutils

package
v0.18.0-b1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DnsLen = 12

Variables

View Source
var (
	Rdatatypes = map[int]string{
		0:     "NONE",
		1:     "A",
		2:     "NS",
		3:     "MD",
		4:     "MF",
		5:     "CNAME",
		6:     "SOA",
		7:     "MB",
		8:     "MG",
		9:     "MR",
		10:    "NULL",
		11:    "WKS",
		12:    "PTR",
		13:    "HINFO",
		14:    "MINFO",
		15:    "MX",
		16:    "TXT",
		17:    "RP",
		18:    "AFSDB",
		19:    "X25",
		20:    "ISDN",
		21:    "RT",
		22:    "NSAP",
		23:    "NSAP_PTR",
		24:    "SIG",
		25:    "KEY",
		26:    "PX",
		27:    "GPOS",
		28:    "AAAA",
		29:    "LOC",
		30:    "NXT",
		33:    "SRV",
		35:    "NAPTR",
		36:    "KX",
		37:    "CERT",
		38:    "A6",
		39:    "DNAME",
		41:    "OPT",
		42:    "APL",
		43:    "DS",
		44:    "SSHFP",
		45:    "IPSECKEY",
		46:    "RRSIG",
		47:    "NSEC",
		48:    "DNSKEY",
		49:    "DHCID",
		50:    "NSEC3",
		51:    "NSEC3PARAM",
		52:    "TSLA",
		53:    "SMIMEA",
		55:    "HIP",
		56:    "NINFO",
		59:    "CDS",
		60:    "CDNSKEY",
		61:    "OPENPGPKEY",
		62:    "CSYNC",
		64:    "SVCB",
		65:    "HTTPS",
		99:    "SPF",
		103:   "UNSPEC",
		108:   "EUI48",
		109:   "EUI64",
		249:   "TKEY",
		250:   "TSIG",
		251:   "IXFR",
		252:   "AXFR",
		253:   "MAILB",
		254:   "MAILA",
		255:   "ANY",
		256:   "URI",
		257:   "CAA",
		258:   "AVC",
		259:   "AMTRELAY",
		32768: "TA",
		32769: "DLV",
	}
	Rcodes = map[int]string{
		0:  "NOERROR",
		1:  "FORMERR",
		2:  "SERVFAIL",
		3:  "NXDOMAIN",
		4:  "NOIMP",
		5:  "REFUSED",
		6:  "YXDOMAIN",
		7:  "YXRRSET",
		8:  "NXRRSET",
		9:  "NOTAUTH",
		10: "NOTZONE",
		11: "DSOTYPENI",
		16: "BADSIG",
		17: "BADKEY",
		18: "BADTIME",
		19: "BADMODE",
		20: "BADNAME",
		21: "BADALG",
		22: "BADTRUNC",
		23: "BADCOOKIE",
	}
)
View Source
var (
	OptCodes = map[int]string{
		3:  "NSID",
		8:  "CSUBNET",
		9:  "EXPIRE",
		10: "COOKIE",
		11: "KEEPALIVE",
		12: "PADDING",
		15: "ERRORS",
	}
	ErrorCodeToString = map[int]string{
		0:  "Other",
		1:  "Unsupported DNSKEY Algorithm",
		2:  "Unsupported DS Digest Type",
		3:  "Stale Answer",
		4:  "Forged Answer",
		5:  "DNSSEC Indeterminate",
		6:  "DNSSEC Bogus",
		7:  "Signature Expired",
		8:  "Signature Not Yet Valid",
		9:  "DNSKEY Missing",
		10: "RRSIGs Missing",
		11: "No Zone Key Bit Set",
		12: "NSEC Missing",
		13: "Cached Error",
		14: "Not Ready",
		15: "Blocked",
		16: "Censored",
		17: "Filtered",
		18: "Prohibited",
		19: "Stale NXDOMAIN Answer",
		20: "Not Authoritative",
		21: "Not Supported",
		22: "No Reachable Authority",
		23: "Network Error",
		24: "Invalid Data",
	}
)
View Source
var (
	DnsQuery = "QUERY"
	DnsReply = "REPLY"
)
View Source
var ErrDecodeDnsAnswerRdataTooShort = errors.New("malformed pkt, not enough data to decode rdata answer")
View Source
var ErrDecodeDnsAnswerTooShort = errors.New("malformed pkt, not enough data to decode answer")
View Source
var ErrDecodeDnsHeaderTooShort = errors.New("malformed pkt, dns payload too short to decode header")
View Source
var ErrDecodeDnsLabelInvalidData = errors.New("malformed pkt, invalid label length byte")
View Source
var ErrDecodeDnsLabelInvalidOffset = errors.New("malformed pkt, invalid offset to decode label")
View Source
var ErrDecodeDnsLabelInvalidPointer = errors.New("malformed pkt, label pointer not pointing to prior data")
View Source
var ErrDecodeDnsLabelTooLong = errors.New("malformed pkt, label too long")
View Source
var ErrDecodeDnsLabelTooShort = errors.New("malformed pkt, dns payload too short to get label")
View Source
var ErrDecodeEdnsBadRootDomain = errors.New("edns, name MUST be 0 (root domain)")
View Source
var ErrDecodeEdnsDataTooShort = errors.New("edns, not enough data to decode rdata answer")
View Source
var ErrDecodeEdnsOptionCsubnetBadFamily = errors.New("edns, csubnet option bad family")
View Source
var ErrDecodeEdnsOptionTooShort = errors.New("edns, not enough data to decode option answer")
View Source
var ErrDecodeEdnsTooManyOpts = errors.New("edns, packet contained too many OPT RRs")
View Source
var ErrDecodeQuestionQtypeTooShort = errors.New("malformed pkt, not enough data to decode qtype")

Functions

func DecodeQuestion added in v0.14.0

func DecodeQuestion(qdcount int, payload []byte) (string, int, int, error)

DNS QUESTION

							   1  1  1  1  1  1
 0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5

+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | / QNAME / / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | QTYPE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | QCLASS | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

func IsValidMode added in v0.11.0

func IsValidMode(mode string) bool

func OptCodeToString added in v0.14.0

func OptCodeToString(rcode int) string

func ParseA added in v0.14.0

func ParseA(r []byte) (string, error)

IPv4

								1  1  1  1  1  1
  0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5

+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | ADDRESS | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

func ParseAAAA added in v0.14.0

func ParseAAAA(rdata []byte) (string, error)

IPv6

								1  1  1  1  1  1
  0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5

+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | | | | | | ADDRESS | | | | | | | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

func ParseCNAME added in v0.14.0

func ParseCNAME(rdata_offset int, payload []byte) (string, error)

CNAME

								1  1  1  1  1  1
  0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5

+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ / NAME / / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

func ParseCsubnet added in v0.14.0

func ParseCsubnet(d []byte) (string, error)
https://datatracker.ietf.org/doc/html/rfc7871

Extended Csubnet EDNS0 option format
                                            1   1   1   1   1   1
    0   1   2   3   4   5   6   7   8   9   0   1   2   3   4   5
  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

4: | FAMILY |

+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

6: | SOURCE PREFIX-LENGTH | SCOPE PREFIX-LENGTH |

+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

8: | ADDRESS... /

+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

func ParseErrors added in v0.14.0

func ParseErrors(d []byte) (string, error)
https://datatracker.ietf.org/doc/html/rfc8914

Extended Error EDNS0 option format
                                            1   1   1   1   1   1
    0   1   2   3   4   5   6   7   8   9   0   1   2   3   4   5
  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

4: | INFO-CODE |

+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

6: / EXTRA-TEXT ... /

+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

func ParseLabels added in v0.14.0

func ParseLabels(offset int, payload []byte) (string, int, error)

func ParseMX added in v0.14.0

func ParseMX(rdata_offset int, payload []byte) (string, error)

MX

								1  1  1  1  1  1
  0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5

+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | PREFERENCE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ / EXCHANGE / / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

func ParseNS added in v0.14.0

func ParseNS(rdata_offset int, payload []byte) (string, error)

NS

								1  1  1  1  1  1
  0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5

+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ / NSDNAME / / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

func ParseOption added in v0.14.0

func ParseOption(optName string, optData []byte) (string, error)

func ParsePTR added in v0.14.0

func ParsePTR(rdata_offset int, payload []byte) (string, error)

PTR

								1  1  1  1  1  1
	0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/                   PTRDNAME                    /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

func ParseRdata added in v0.14.0

func ParseRdata(rdatatype string, rdata []byte, payload []byte, rdata_offset int) (string, error)

func ParseSOA added in v0.14.0

func ParseSOA(rdata_offset int, payload []byte) (string, error)

SOA

								1  1  1  1  1  1
  0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5

+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ / MNAME / / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ / RNAME / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | SERIAL | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | REFRESH | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | RETRY | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | EXPIRE | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | MINIMUM | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

func ParseSRV added in v0.14.0

func ParseSRV(rdata_offset int, payload []byte) (string, error)

SRV

								1  1  1  1  1  1
  0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5

+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | PRIORITY | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | WEIGHT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | PORT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | TARGET | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

func ParseTXT added in v0.14.0

func ParseTXT(rdata []byte) (string, error)

TXT

								1  1  1  1  1  1
  0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5

+--+--+--+--+--+--+--+--+ | LENGTH | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ / TXT-DATA / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

func RcodeToString added in v0.14.0

func RcodeToString(rcode int) string

func RdatatypeToString added in v0.14.0

func RdatatypeToString(rrtype int) string

func ReloadConfig added in v0.16.0

func ReloadConfig(configPath string, config *Config) error

Types

type Config

type Config struct {
	Trace struct {
		Verbose      bool   `yaml:"verbose"`
		LogMalformed bool   `yaml:"log-malformed"`
		Filename     string `yaml:"filename"`
		MaxSize      int    `yaml:"max-size"`
		MaxBackups   int    `yaml:"max-backups"`
	} `yaml:"trace"`

	Collectors struct {
		Tail struct {
			Enable       bool   `yaml:"enable"`
			TimeLayout   string `yaml:"time-layout"`
			PatternQuery string `yaml:"pattern-query"`
			PatternReply string `yaml:"pattern-reply"`
			FilePath     string `yaml:"file-path"`
		} `yaml:"tail"`
		Dnstap struct {
			Enable     bool   `yaml:"enable"`
			ListenIP   string `yaml:"listen-ip"`
			ListenPort int    `yaml:"listen-port"`
			SockPath   string `yaml:"sock-path"`
			TlsSupport bool   `yaml:"tls-support"`
			CertFile   string `yaml:"cert-file"`
			KeyFile    string `yaml:"key-file"`
		} `yaml:"dnstap"`
		DnsSniffer struct {
			Enable            bool   `yaml:"enable"`
			Port              int    `yaml:"port"`
			Device            string `yaml:"device"`
			CaptureDnsQueries bool   `yaml:"capture-dns-queries"`
			CaptureDnsReplies bool   `yaml:"capture-dns-replies"`
		} `yaml:"dns-sniffer"`
		PowerDNS struct {
			Enable     bool   `yaml:"enable"`
			ListenIP   string `yaml:"listen-ip"`
			ListenPort int    `yaml:"listen-port"`
		} `yaml:"powerdns"`
	} `yaml:"collectors"`

	Subprocessors struct {
		QuietText struct {
			Dnstap bool `yaml:"dnstap"`
			Dns    bool `yaml:"dns"`
		} `yaml:"quiet-text"`
		Statistics struct {
			TopMaxItems        int      `yaml:"top-max-items"`
			ThresholdQnameLen  int      `yaml:"threshold-qname-len"`
			ThresholdPacketLen int      `yaml:"threshold-packet-len"`
			ThresholdSlow      float64  `yaml:"threshold-slow"`
			CommonQtypes       []string `yaml:"common-qtypes,flow"`
			PromPrefix         string   `yaml:"prometheus-prefix"`
		} `yaml:"statistics"`
		UserPrivacy struct {
			AnonymizeIP   bool `yaml:"anonymize-ip"`
			MinimazeQname bool `yaml:"minimaze-qname"`
		} `yaml:"user-privacy"`
		QnameLowerCase bool `yaml:"qname-lowercase"`
		Cache          struct {
			Enable       bool `yaml:"enable"`
			QueryTimeout int  `yaml:"query-timeout"`
		} `yaml:"cache"`
		ServerId  string `yaml:"server-id"`
		Filtering struct {
			DropFqdnFile    string   `yaml:"drop-fqdn-file"`
			DropDomainFile  string   `yaml:"drop-domain-file"`
			DropQueryIpFile string   `yaml:"drop-queryip-file"`
			KeepQueryIpFile string   `yaml:"keep-queryip-file"`
			DropRcodes      []string `yaml:"drop-rcodes,flow"`
			LogQueries      bool     `yaml:"log-queries"`
			LogReplies      bool     `yaml:"log-replies"`
		} `yaml:"filtering"`
		GeoIP struct {
			DbCountryFile string `yaml:"mmdb-country-file"`
			DbCityFile    string `yaml:"mmdb-city-file"`
			DbAsnFile     string `yaml:"mmdb-asn-file"`
		} `yaml:"geoip"`
		TextFormat string `yaml:"text-format"`
	} `yaml:"subprocessors"`

	Loggers struct {
		Stdout struct {
			Enable     bool   `yaml:"enable"`
			Mode       string `yaml:"mode"`
			TextFormat string `yaml:"text-format"`
		} `yaml:"stdout"`
		Prometheus struct {
			Enable         bool   `yaml:"enable"`
			ListenIP       string `yaml:"listen-ip"`
			ListenPort     int    `yaml:"listen-port"`
			BasicAuthLogin string `yaml:"basic-auth-login"`
			BasicAuthPwd   string `yaml:"basic-auth-pwd"`
			TlsSupport     bool   `yaml:"tls-support"`
			CertFile       string `yaml:"cert-file"`
			KeyFile        string `yaml:"key-file"`
			PromPrefix     string `yaml:"prometheus-prefix"`
		} `yaml:"prometheus"`
		WebServer struct {
			Enable         bool   `yaml:"enable"`
			ListenIP       string `yaml:"listen-ip"`
			ListenPort     int    `yaml:"listen-port"`
			BasicAuthLogin string `yaml:"basic-auth-login"`
			BasicAuthPwd   string `yaml:"basic-auth-pwd"`
			TlsSupport     bool   `yaml:"tls-support"`
			CertFile       string `yaml:"cert-file"`
			KeyFile        string `yaml:"key-file"`
		} `yaml:"webserver"`
		LogFile struct {
			Enable              bool   `yaml:"enable"`
			FilePath            string `yaml:"file-path"`
			MaxSize             int    `yaml:"max-size"`
			MaxFiles            int    `yaml:"max-files"`
			FlushInterval       int    `yaml:"flush-interval"`
			Compress            bool   `yaml:"compress"`
			CompressInterval    int    `yaml:"compress-interval"`
			CompressPostCommand string `yaml:"compress-postcommand"`
			Mode                string `yaml:"mode"`
			PostRotateCommand   string `yaml:"postrotate-command"`
			PostRotateDelete    bool   `yaml:"postrotate-delete-success"`
			TextFormat          string `yaml:"text-format"`
		} `yaml:"logfile"`
		Dnstap struct {
			Enable        bool   `yaml:"enable"`
			RemoteAddress string `yaml:"remote-address"`
			RemotePort    int    `yaml:"remote-port"`
			SockPath      string `yaml:"sock-path"`
			RetryInterval int    `yaml:"retry-interval"`
			TlsSupport    bool   `yaml:"tls-support"`
			TlsInsecure   bool   `yaml:"tls-insecure"`
		} `yaml:"dnstap"`
		TcpClient struct {
			Enable        bool   `yaml:"enable"`
			RemoteAddress string `yaml:"remote-address"`
			RemotePort    int    `yaml:"remote-port"`
			SockPath      string `yaml:"sock-path"`
			RetryInterval int    `yaml:"retry-interval"`
			Transport     string `yaml:"transport"`
			TlsSupport    bool   `yaml:"tls-support"`
			TlsInsecure   bool   `yaml:"tls-insecure"`
			Mode          string `yaml:"mode"`
			TextFormat    string `yaml:"text-format"`
			Delimiter     string `yaml:"delimiter"`
		} `yaml:"tcpclient"`
		Syslog struct {
			Enable        bool   `yaml:"enable"`
			Severity      string `yaml:"severity"`
			Facility      string `yaml:"facility"`
			Transport     string `yaml:"transport"`
			RemoteAddress string `yaml:"remote-address"`
			TextFormat    string `yaml:"text-format"`
			Mode          string `yaml:"mode"`
			TlsSupport    bool   `yaml:"tls-support"`
			TlsInsecure   bool   `yaml:"tls-insecure"`
		} `yaml:"syslog"`
		Fluentd struct {
			Enable        bool   `yaml:"enable"`
			RemoteAddress string `yaml:"remote-address"`
			RemotePort    int    `yaml:"remote-port"`
			SockPath      string `yaml:"sock-path"`
			RetryInterval int    `yaml:"retry-interval"`
			Transport     string `yaml:"transport"`
			TlsSupport    bool   `yaml:"tls-support"`
			TlsInsecure   bool   `yaml:"tls-insecure"`
			Tag           string `yaml:"tag"`
		} `yaml:"fluentd"`
		PcapFile struct {
			Enable            bool   `yaml:"enable"`
			FilePath          string `yaml:"file-path"`
			MaxSize           int    `yaml:"max-size"`
			MaxFiles          int    `yaml:"max-files"`
			Compress          bool   `yaml:"compress"`
			CompressInterval  int    `yaml:"compress-interval"`
			PostRotateCommand string `yaml:"postrotate-command"`
			PostRotateDelete  bool   `yaml:"postrotate-delete-success"`
		} `yaml:"pcapfile"`
		InfluxDB struct {
			Enable       bool   `yaml:"enable"`
			ServerURL    string `yaml:"server-url"`
			AuthToken    string `yaml:"auth-token"`
			TlsSupport   bool   `yaml:"tls-support"`
			TlsInsecure  bool   `yaml:"tls-insecure"`
			Bucket       string `yaml:"bucket"`
			Organization string `yaml:"organization"`
		} `yaml:"influxdb"`
		LokiClient struct {
			Enable         bool   `yaml:"enable"`
			ServerURL      string `yaml:"server-url"`
			JobName        string `yaml:"job-name"`
			Mode           string `yaml:"mode"`
			FlushInterval  int    `yaml:"flush-interval"`
			BatchSize      int    `yaml:"batch-size"`
			RetryInterval  int    `yaml:"retry-interval"`
			TextFormat     string `yaml:"text-format"`
			ProxyURL       string `yaml:"proxy-url"`
			TlsInsecure    bool   `yaml:"tls-insecure"`
			BasicAuthLogin string `yaml:"basic-auth-login"`
			BasicAuthPwd   string `yaml:"basic-auth-pwd"`
			TenantId       string `yaml:"tenant-id"`
		} `yaml:"lokiclient"`
		Statsd struct {
			Enable        bool   `yaml:"enable"`
			Prefix        string `yaml:"prefix"`
			RemoteAddress string `yaml:"remote-address"`
			RemotePort    int    `yaml:"remote-port"`
			Transport     string `yaml:"transport"`
			FlushInterval int    `yaml:"flush-interval"`
			TlsSupport    bool   `yaml:"tls-support"`
			TlsInsecure   bool   `yaml:"tls-insecure"`
		} `yaml:"statsd"`
	} `yaml:"loggers"`
}

func GetFakeConfig

func GetFakeConfig() *Config

func LoadConfig

func LoadConfig(configPath string) (*Config, error)

func (*Config) SetDefault

func (c *Config) SetDefault()

type Dns added in v0.14.0

type Dns struct {
	Type                     string   `json:"-" msgpack:"-"`
	Payload                  []byte   `json:"-" msgpack:"-"`
	Length                   int      `json:"length" msgpack:"-"`
	Id                       int      `json:"-" msgpack:"-"`
	Opcode                   int      `json:"opcode" msgpack:"opcode"`
	Rcode                    string   `json:"rcode" msgpack:"rcode"`
	Qname                    string   `json:"qname" msgpack:"qname"`
	QnamePublicSuffix        string   `json:"qname-public-suffix" msgpack:"qname-public-suffix"`
	QnameEffectiveTLDPlusOne string   `json:"qname-effective-tld-plus-one" msgpack:"qname-effective-tld-plus-one"`
	Qtype                    string   `json:"qtype" msgpack:"qtype"`
	Flags                    DnsFlags `json:"flags" msgpack:"flags"`
	DnsRRs                   DnsRRs   `json:"resource-records" msgpack:"resource-records"`
	MalformedPacket          int      `json:"malformed-packet" msgpack:"malformed-packet"`
}

type DnsAnswer

type DnsAnswer struct {
	Name      string `json:"name" msgpack:"name"`
	Rdatatype string `json:"rdatatype" msgpack:"rdatatype"`
	Class     int    `json:"-" msgpack:"-"`
	Ttl       int    `json:"ttl" msgpack:"ttl"`
	Rdata     string `json:"rdata" msgpack:"rdata"`
}

func DecodeAnswer added in v0.14.0

func DecodeAnswer(ancount int, start_offset int, payload []byte) ([]DnsAnswer, int, error)

type DnsExtended added in v0.14.0

type DnsExtended struct {
	UdpSize       int         `json:"udp-size" msgpack:"udp-size"`
	ExtendedRcode int         `json:"rcode" msgpack:"rcode"`
	Version       int         `json:"version" msgpack:"version"`
	Do            int         `json:"dnssec-ok" msgpack:"dnssec-ok"`
	Z             int         `json:"-" msgpack:"-"`
	Options       []DnsOption `json:"options" msgpack:"options"`
}

func DecodeEDNS added in v0.14.0

func DecodeEDNS(arcount int, start_offset int, payload []byte) (DnsExtended, int, error)

type DnsFlags added in v0.14.0

type DnsFlags struct {
	QR bool `json:"qr" msgpack:"qr"`
	TC bool `json:"tc" msgpack:"tc"`
	AA bool `json:"aa" msgpack:"aa"`
	RA bool `json:"ra" msgpack:"ra"`
	AD bool `json:"ad" msgpack:"ad"`
}

type DnsGeo added in v0.14.0

type DnsGeo struct {
	City           string `json:"city" msgpack:"city"`
	Continent      string `json:"continent" msgpack:"continent"`
	CountryIsoCode string `json:"country-isocode" msgpack:"country-isocode"`
}

type DnsHeader added in v0.14.0

type DnsHeader struct {
	Id      int
	Qr      int
	Opcode  int
	Aa      int
	Tc      int
	Rd      int
	Ra      int
	Z       int
	Ad      int
	Cd      int
	Rcode   int
	Qdcount int
	Ancount int
	Nscount int
	Arcount int
}

func DecodeDns added in v0.14.0

func DecodeDns(payload []byte) (DnsHeader, error)

type DnsMessage

type DnsMessage struct {
	NetworkInfo DnsNetInfo  `json:"network" msgpack:"network"`
	DNS         Dns         `json:"dns" msgpack:"dns"`
	EDNS        DnsExtended `json:"edns" msgpack:"edns"`
	DnsTap      DnsTap      `json:"dnstap" msgpack:"dnstap"`
	Geo         DnsGeo      `json:"geo" msgpack:"geo"`
	PowerDns    PowerDns    `json:"pdns" msgpack:"pdns"`
}

func GetFakeDnsMessage

func GetFakeDnsMessage() DnsMessage

func (*DnsMessage) Bytes

func (dm *DnsMessage) Bytes(format []string, delimiter string) []byte

func (*DnsMessage) Init

func (dm *DnsMessage) Init()

func (*DnsMessage) String

func (dm *DnsMessage) String(format []string) string

type DnsNetInfo added in v0.14.0

type DnsNetInfo struct {
	Family                 string `json:"family" msgpack:"family"`
	Protocol               string `json:"protocol" msgpack:"protocol"`
	QueryIp                string `json:"query-ip" msgpack:"query-ip"`
	QueryPort              string `json:"query-port" msgpack:"query-port"`
	ResponseIp             string `json:"response-ip" msgpack:"response-ip"`
	ResponsePort           string `json:"response-port" msgpack:"response-port"`
	AutonomousSystemNumber string `json:"as-number" msgpack:"as-number"`
	AutonomousSystemOrg    string `json:"as-owner" msgpack:"as-owner"`
}

type DnsOption added in v0.14.0

type DnsOption struct {
	Code int    `json:"code" msgpack:"code"`
	Name string `json:"name" msgpack:"name"`
	Data string `json:"data" msgpack:"data"`
}

type DnsRRs added in v0.14.0

type DnsRRs struct {
	Answers     []DnsAnswer `json:"an" msgpack:"an"`
	Nameservers []DnsAnswer `json:"ns" msgpack:"ns"`
	Records     []DnsAnswer `json:"ar" msgpack:"ar"`
}

type DnsTap added in v0.14.0

type DnsTap struct {
	Operation        string  `json:"operation" msgpack:"operation"`
	Identity         string  `json:"identity" msgpack:"identity"`
	TimestampRFC3339 string  `json:"timestamp-rfc3339ns" msgpack:"timestamp-rfc3339ns"`
	Timestamp        float64 `json:"-" msgpack:"-"`
	TimeSec          int     `json:"-" msgpack:"-"`
	TimeNsec         int     `json:"-" msgpack:"-"`
	Latency          float64 `json:"-" msgpack:"-"`
	LatencySec       string  `json:"latency" msgpack:"latency"`
}

type PowerDns added in v0.18.0

type PowerDns struct {
	Tags []string `json:"tags" msgpack:"tags"`
}

type Worker

type Worker interface {
	Stop()
	Run()
	Channel() chan DnsMessage
	ReadConfig()
}

Jump to

Keyboard shortcuts

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