fix(output): change output file structure
This commit is contained in:
@@ -17,7 +17,7 @@ def map_server_to_resolver(server):
|
|||||||
elif 'adguard' in server_lower:
|
elif 'adguard' in server_lower:
|
||||||
return 'AdGuard'
|
return 'AdGuard'
|
||||||
else:
|
else:
|
||||||
return server # Fallback to original server name
|
return server
|
||||||
|
|
||||||
def extract_from_new_format(filename):
|
def extract_from_new_format(filename):
|
||||||
"""Parse new filename format: protocol[-flags]-timestamp.csv"""
|
"""Parse new filename format: protocol[-flags]-timestamp.csv"""
|
||||||
@@ -41,10 +41,10 @@ def extract_server_info(file_path, dns_server_field):
|
|||||||
"""Extract info using directory structure and filename"""
|
"""Extract info using directory structure and filename"""
|
||||||
path = Path(file_path)
|
path = Path(file_path)
|
||||||
|
|
||||||
# Expect structure like: results/date/server/filename.csv
|
# Expect structure like: results/resolver/date/filename.csv
|
||||||
parts = path.parts
|
parts = path.parts
|
||||||
if len(parts) >= 3 and parts[-3].isdigit() and len(parts[-3]) == 10: # date folder like 2024-03-01
|
if len(parts) >= 3 and parts[-2].isdigit() and len(parts[-2]) == 10: # date folder like 2024-03-01
|
||||||
server = parts[-2] # server folder
|
server = parts[-3] # resolver folder (e.g., cloudflare)
|
||||||
filename = parts[-1]
|
filename = parts[-1]
|
||||||
|
|
||||||
protocol, dnssec_status, keepalive_status = extract_from_new_format(filename)
|
protocol, dnssec_status, keepalive_status = extract_from_new_format(filename)
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ func GenerateOutputPaths(outputDir, upstream string, dnssec, keepAlive bool) (cs
|
|||||||
|
|
||||||
// Create date-based subdirectory
|
// Create date-based subdirectory
|
||||||
date := time.Now().Format("2006-01-02")
|
date := time.Now().Format("2006-01-02")
|
||||||
timestamp := time.Now().Format("150405")
|
timestamp := time.Now().Format("150405") // HHMMSS for uniqueness
|
||||||
|
|
||||||
// Organize by date and server
|
// Organize hierarchically: resolver/date/filename
|
||||||
subDir := filepath.Join(outputDir, date, cleanServer)
|
subDir := filepath.Join(outputDir, cleanServer, date)
|
||||||
|
|
||||||
// Create simple filename
|
// Create simple filename
|
||||||
base := proto
|
base := proto
|
||||||
@@ -44,7 +44,7 @@ func GenerateOutputPaths(outputDir, upstream string, dnssec, keepAlive bool) (cs
|
|||||||
}
|
}
|
||||||
|
|
||||||
func cleanServerName(server string) string {
|
func cleanServerName(server string) string {
|
||||||
// Map common servers to short names
|
// Map common servers to readable names
|
||||||
serverMap := map[string]string{
|
serverMap := map[string]string{
|
||||||
"1.1.1.1": "cloudflare",
|
"1.1.1.1": "cloudflare",
|
||||||
"1.0.0.1": "cloudflare",
|
"1.0.0.1": "cloudflare",
|
||||||
@@ -57,20 +57,22 @@ func cleanServerName(server string) string {
|
|||||||
"9.9.9.9": "quad9",
|
"9.9.9.9": "quad9",
|
||||||
"149.112.112.112": "quad9",
|
"149.112.112.112": "quad9",
|
||||||
"dns.quad9.net": "quad9",
|
"dns.quad9.net": "quad9",
|
||||||
|
"dns10.quad9.net": "quad9",
|
||||||
"208.67.222.222": "opendns",
|
"208.67.222.222": "opendns",
|
||||||
"208.67.220.220": "opendns",
|
"208.67.220.220": "opendns",
|
||||||
"resolver1.opendns.com": "opendns",
|
"resolver1.opendns.com": "opendns",
|
||||||
"94.140.14.14": "adguard",
|
"94.140.14.14": "adguard",
|
||||||
"94.140.15.15": "adguard",
|
"94.140.15.15": "adguard",
|
||||||
"dns.adguard.com": "adguard",
|
"dns.adguard.com": "adguard",
|
||||||
|
"dns.adguard-dns.com": "adguard",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean the server name first
|
// Clean the server name first
|
||||||
cleaned := strings.ToLower(server)
|
cleaned := strings.ToLower(server)
|
||||||
cleaned = strings.TrimPrefix(cleaned, "https://")
|
cleaned = strings.TrimPrefix(cleaned, "https://")
|
||||||
cleaned = strings.TrimPrefix(cleaned, "http://")
|
cleaned = strings.TrimPrefix(cleaned, "http://")
|
||||||
cleaned = strings.Split(cleaned, "/")[0] // Remove path
|
cleaned = strings.Split(cleaned, "/")[0]
|
||||||
cleaned = strings.Split(cleaned, ":")[0] // Remove port
|
cleaned = strings.Split(cleaned, ":")[0]
|
||||||
|
|
||||||
// Check if we have a mapping
|
// Check if we have a mapping
|
||||||
if shortName, exists := serverMap[cleaned]; exists {
|
if shortName, exists := serverMap[cleaned]; exists {
|
||||||
|
|||||||
Reference in New Issue
Block a user