Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use default lib for config #714

Merged
merged 12 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GO_DNSTAP_PROTOBUF := 1.0.1
GO_FRAMESTREAM := 0.10.0
GO_CLIENTSYSLOG := 0.4.0
GO_TOPMAP := 1.0.0
GO_NETUTILS := 0.1.0
GO_NETUTILS := 0.2.0

BUILD_TIME := $(shell LANG=en_US date +"%F_%T_%z")
COMMIT := $(shell git rev-parse --short HEAD)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<p align="center">
<img src="https://goreportcard.com/badge/github.com/dmachard/go-dns-collector" alt="Go Report"/>
<img src="https://img.shields.io/badge/go%20version-min%201.21-green" alt="Go version"/>
<img src="https://img.shields.io/badge/go%20tests-428-green" alt="Go tests"/>
<img src="https://img.shields.io/badge/go%20tests-427-green" alt="Go tests"/>
<img src="https://img.shields.io/badge/go%20bench-20-green" alt="Go bench"/>
<img src="https://img.shields.io/badge/go%20lines-31698-green" alt="Go lines"/>
<img src="https://img.shields.io/badge/go%20lines-30545-green" alt="Go lines"/>
</p>

<p align="center">
Expand Down
145 changes: 28 additions & 117 deletions dnsutils/dns_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,111 +14,34 @@ const DNSLen = 12
const UNKNOWN = "UNKNOWN"

var (
Class = map[int]string{
1: "IN",
3: "CH",
4: "HS",
254: "NONE",
255: "ANY",
}
Class = map[int]string{1: "IN", 3: "CH", 4: "HS", 254: "NONE", 255: "ANY"}
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",
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",
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",
}
)

Expand Down Expand Up @@ -169,21 +92,9 @@ func (e *decodingError) Unwrap() error {
}

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
ID, Qr, Opcode, Rcode int
Aa, Tc, Rd, Ra, Z, Ad, Cd int
Qdcount, Ancount, Nscount, Arcount int
}

/*
Expand Down
8 changes: 1 addition & 7 deletions dnsutils/edns_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ var ErrDecodeEdnsTooManyOpts = errors.New("edns, packet contained too many OPT R

var (
OptCodes = map[int]string{
3: "NSID",
8: "CSUBNET",
9: "EXPIRE",
10: "COOKIE",
11: "KEEPALIVE",
12: "PADDING",
15: "ERRORS",
3: "NSID", 8: "CSUBNET", 9: "EXPIRE", 10: "COOKIE", 11: "KEEPALIVE", 12: "PADDING", 15: "ERRORS",
}
ErrorCodeToString = map[int]string{
0: "Other",
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ require (
github.com/IBM/fluent-forward-go v0.2.2
github.com/IBM/sarama v1.43.2
github.com/cilium/ebpf v0.15.0
github.com/creasty/defaults v1.7.0
github.com/dmachard/go-clientsyslog v0.4.0
github.com/dmachard/go-dnstap-protobuf v1.0.1
github.com/dmachard/go-framestream v0.10.0
github.com/dmachard/go-logger v0.4.0
github.com/dmachard/go-netutils v0.1.0
github.com/dmachard/go-netutils v0.2.0
github.com/dmachard/go-powerdns-protobuf v1.1.1
github.com/dmachard/go-topmap v1.0.0
github.com/farsightsec/golang-framestream v0.3.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@ github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creasty/defaults v1.7.0 h1:eNdqZvc5B509z18lD8yc212CAqJNvfT1Jq6L8WowdBA=
github.com/creasty/defaults v1.7.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -477,6 +479,8 @@ github.com/dmachard/go-logger v0.4.0 h1:JJJW8C5Ri6OaWIECAE6dUNqLs4ym1+WX3xD6h5Mx
github.com/dmachard/go-logger v0.4.0/go.mod h1:Gf6Au3CX5l3rZ+Tb3yX31u6h4lwVeZQSBklUI3h8gCA=
github.com/dmachard/go-netutils v0.1.0 h1:VdlUeUvpv7t4iPbNfHIKRC0itE/OwEZRl/GIdsc0mqc=
github.com/dmachard/go-netutils v0.1.0/go.mod h1:KgAYMuJcF+1Xwtm0SlpJ4S7jBvkFghj+7tFesaHv3BY=
github.com/dmachard/go-netutils v0.2.0 h1:jizdNnEftIPOf+f3bUg2yWorX8wDQjBfeXYPAS6zGp8=
github.com/dmachard/go-netutils v0.2.0/go.mod h1:KgAYMuJcF+1Xwtm0SlpJ4S7jBvkFghj+7tFesaHv3BY=
github.com/dmachard/go-powerdns-protobuf v1.1.1 h1:HhgkjPGJN9QCLVFWxiTIwP3E0He8ET9uJZaT7/+6HXw=
github.com/dmachard/go-powerdns-protobuf v1.1.1/go.mod h1:3sewpdCN4u5KpXBxrLpidHAC18v24y+f4OZ4GKfLaME=
github.com/dmachard/go-topmap v1.0.0 h1:FzCnB80WJMSPhpEfWt/79y97XotTQjhlrsXKR6435ow=
Expand Down
Loading
Loading