Docfix: cleanup

This commit is contained in:
2025-10-09 17:58:40 +02:00
parent 97f3adbb31
commit 52f576d025
5 changed files with 49 additions and 18 deletions

View File

@@ -1,3 +1,12 @@
// Package dns implements DNS protocol detection.
//
// This package doesn't expose any public functions, but registers itself for use in protocol detection.
//
// # How to use this package
//
// Import this package into your project in order to enable DNS protocol detection:
//
// import _ "git.maze.io/go/dpi/protocol/detect/dns" // Register DNS protocol detection
package dns
import (
@@ -11,8 +20,8 @@ import (
"git.maze.io/go/dpi/protocol"
)
// Name is the DNS protocol name.
const Name = "dns"
// protocolName is the DNS protocol name.
const protocolName = "dns"
var (
classTypeScoreUnknown = -.15
@@ -47,10 +56,11 @@ var (
func init() {
// Every DNS packet (query or answer) has a 12-byte header.
log.Println("register DetectDNS")
protocol.Register(protocol.Both, "????????????", DetectDNS)
protocol.Register(protocol.Both, "????????????", detectDNS)
}
func DetectDNS(dir protocol.Direction, data []byte, srcPort, dstPort int) (proto *protocol.Protocol, confidence float64) {
// detectDNS can detect DNS queries and answersr from the provided data.
func detectDNS(dir protocol.Direction, data []byte, srcPort, dstPort int) (proto *protocol.Protocol, confidence float64) {
log.Printf("detect dns: %q", hex.EncodeToString(data))
// Parsing using miekg/dns
@@ -146,6 +156,6 @@ func DetectDNS(dir protocol.Direction, data []byte, srcPort, dstPort int) (proto
// to exfiltrate data using malicious queries, etc.
return &protocol.Protocol{
Name: Name,
Name: protocolName,
}, confidence
}