feat(dnssec): add auth and trust dnssec

This commit is contained in:
2025-09-28 13:11:58 +01:00
parent 4a549cfea7
commit a966c1e98d
10 changed files with 345 additions and 184 deletions

View File

@@ -17,13 +17,14 @@ import (
)
type MeasurementConfig struct {
DomainsFile string
OutputDir string
QueryType string
DNSSEC bool
KeepAlive bool
Interface string
Servers []string
DomainsFile string
OutputDir string
QueryType string
DNSSEC bool
AuthoritativeDNSSEC bool
KeepAlive bool
Interface string
Servers []string
}
type MeasurementRunner struct {
@@ -76,7 +77,7 @@ func (r *MeasurementRunner) runMeasurement(upstream string, domains []string, qT
defer dnsClient.Close()
// Setup output files
csvPath, pcapPath := GenerateOutputPaths(r.config.OutputDir, upstream, r.config.DNSSEC, r.config.KeepAlive)
csvPath, pcapPath := GenerateOutputPaths(r.config.OutputDir, upstream, r.config.DNSSEC, r.config.AuthoritativeDNSSEC, r.config.KeepAlive)
// Create directory if it doesn't exist
if err := os.MkdirAll(filepath.Dir(csvPath), 0755); err != nil {
@@ -90,7 +91,7 @@ func (r *MeasurementRunner) runMeasurement(upstream string, domains []string, qT
// Show relative path for cleaner output
relPath, _ := filepath.Rel(r.config.OutputDir, csvPath)
fmt.Printf(">>> Measuring %s (dnssec=%v%s) → %s\n", upstream, r.config.DNSSEC, keepAliveStr, relPath)
fmt.Printf(">>> Measuring %s (dnssec=%v, auth=%v%s) → %s\n", upstream, r.config.DNSSEC, r.config.AuthoritativeDNSSEC, keepAliveStr, relPath)
// Setup packet capture
packetCapture, err := capture.NewPacketCapture(r.config.Interface, pcapPath)
@@ -112,8 +113,9 @@ func (r *MeasurementRunner) runMeasurement(upstream string, domains []string, qT
func (r *MeasurementRunner) setupDNSClient(upstream string) (client.DNSClient, error) {
opts := client.Options{
DNSSEC: r.config.DNSSEC,
KeepAlive: r.config.KeepAlive,
DNSSEC: r.config.DNSSEC,
AuthoritativeDNSSEC: r.config.AuthoritativeDNSSEC,
KeepAlive: r.config.KeepAlive,
}
return client.New(upstream, opts)
}
@@ -173,13 +175,14 @@ func (r *MeasurementRunner) runQueries(dnsClient client.DNSClient, upstream stri
func (r *MeasurementRunner) performQuery(dnsClient client.DNSClient, domain, upstream, proto string, qType uint16) results.DNSMetric {
metric := results.DNSMetric{
Domain: domain,
QueryType: r.config.QueryType,
Protocol: proto,
DNSSEC: r.config.DNSSEC,
KeepAlive: r.config.KeepAlive,
DNSServer: upstream,
Timestamp: time.Now(),
Domain: domain,
QueryType: r.config.QueryType,
Protocol: proto,
DNSSEC: r.config.DNSSEC,
AuthoritativeDNSSEC: r.config.AuthoritativeDNSSEC,
KeepAlive: r.config.KeepAlive,
DNSServer: upstream,
Timestamp: time.Now(),
}
msg := new(dns.Msg)

View File

@@ -9,19 +9,20 @@ import (
)
type DNSMetric struct {
Domain string `json:"domain"`
QueryType string `json:"query_type"`
Protocol string `json:"protocol"`
DNSSEC bool `json:"dnssec"`
KeepAlive bool `json:"keep_alive"`
DNSServer string `json:"dns_server"`
Timestamp time.Time `json:"timestamp"`
Duration int64 `json:"duration_ns"`
DurationMs float64 `json:"duration_ms"`
RequestSize int `json:"request_size_bytes"`
ResponseSize int `json:"response_size_bytes"`
ResponseCode string `json:"response_code"`
Error string `json:"error,omitempty"`
Domain string `json:"domain"`
QueryType string `json:"query_type"`
Protocol string `json:"protocol"`
DNSSEC bool `json:"dnssec"`
AuthoritativeDNSSEC bool `json:"auth_dnssec"`
KeepAlive bool `json:"keep_alive"`
DNSServer string `json:"dns_server"`
Timestamp time.Time `json:"timestamp"`
Duration int64 `json:"duration_ns"`
DurationMs float64 `json:"duration_ms"`
RequestSize int `json:"request_size_bytes"`
ResponseSize int `json:"response_size_bytes"`
ResponseCode string `json:"response_code"`
Error string `json:"error,omitempty"`
}
type MetricsWriter struct {
@@ -39,7 +40,7 @@ func NewMetricsWriter(path string) (*MetricsWriter, error) {
// Write CSV header
header := []string{
"domain", "query_type", "protocol", "dnssec", "keep_alive",
"domain", "query_type", "protocol", "dnssec", "auth_dnssec", "keep_alive",
"dns_server", "timestamp", "duration_ns", "duration_ms",
"request_size_bytes", "response_size_bytes", "response_code", "error",
}
@@ -63,6 +64,7 @@ func (mw *MetricsWriter) WriteMetric(metric DNSMetric) error {
metric.QueryType,
metric.Protocol,
strconv.FormatBool(metric.DNSSEC),
strconv.FormatBool(metric.AuthoritativeDNSSEC),
strconv.FormatBool(metric.KeepAlive),
metric.DNSServer,
metric.Timestamp.Format(time.RFC3339),

View File

@@ -8,7 +8,7 @@ import (
"time"
)
func GenerateOutputPaths(outputDir, upstream string, dnssec, keepAlive bool) (csvPath, pcapPath string) {
func GenerateOutputPaths(outputDir, upstream string, dnssec, authDNSSEC, keepAlive bool) (csvPath, pcapPath string) {
proto := DetectProtocol(upstream)
cleanServer := cleanServerName(upstream)
@@ -25,7 +25,11 @@ func GenerateOutputPaths(outputDir, upstream string, dnssec, keepAlive bool) (cs
// Add flags if enabled
var flags []string
if dnssec {
flags = append(flags, "dnssec")
if authDNSSEC {
flags = append(flags, "auth")
} else {
flags = append(flags, "trust")
}
}
if keepAlive {
flags = append(flags, "persist")