feat(outputs): use only one output file, appending on every run

This commit is contained in:
2025-10-12 10:39:00 +01:00
parent 98aa70e08f
commit 68d0b5fe4d
3 changed files with 46 additions and 38 deletions

View File

@@ -5,25 +5,17 @@ import (
"net/url"
"path/filepath"
"strings"
"time"
)
func GenerateOutputPaths(outputDir, upstream string, dnssec, authDNSSEC, keepAlive bool) (csvPath, pcapPath string) {
proto := DetectProtocol(upstream)
cleanServer := cleanServerName(upstream)
// Create date-based subdirectory
date := time.Now().Format("2006-01-02")
timestamp := time.Now().Format("150405")
subDir := filepath.Join(outputDir, cleanServer)
// Organize hierarchically: resolver/date/filename
subDir := filepath.Join(outputDir, cleanServer, date)
// Create simple filename
base := proto
// Add flags if enabled
var flags []string
if dnssec {
if authDNSSEC {
flags = append(flags, "auth")
@@ -39,11 +31,8 @@ func GenerateOutputPaths(outputDir, upstream string, dnssec, authDNSSEC, keepAli
base = fmt.Sprintf("%s-%s", base, strings.Join(flags, "-"))
}
// Add timestamp
filename := fmt.Sprintf("%s-%s", base, timestamp)
return filepath.Join(subDir, filename+".csv"),
filepath.Join(subDir, filename+".pcap")
return filepath.Join(subDir, base+".csv"),
filepath.Join(subDir, base+".pcap")
}
func cleanServerName(server string) string {