log out json from dns leak test

This commit is contained in:
Quentin McGaw
2026-06-24 22:25:32 +00:00
parent b5f815640e
commit 4a670635c4
+8 -4
View File
@@ -4,6 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io"
"math" "math"
"math/rand/v2" "math/rand/v2"
"net/http" "net/http"
@@ -84,11 +85,14 @@ func triggerDNSQuery(ctx context.Context, client *http.Client, session string) (
IP map[string]uint `json:"ip"` IP map[string]uint `json:"ip"`
} }
decoder := json.NewDecoder(response.Body) rawData, err := io.ReadAll(response.Body)
var data ipLeakData
err = decoder.Decode(&data)
if err != nil { if err != nil {
return nil, fmt.Errorf("decoding response: %w", err) return nil, fmt.Errorf("reading response body: %w", err)
}
var data ipLeakData
err = json.Unmarshal(rawData, &data)
if err != nil {
return nil, fmt.Errorf("decoding response %q: %w", rawData, err)
} else if data.Session != session { } else if data.Session != session {
return nil, fmt.Errorf("ipleak.net session mismatch: expected %s, got %s", session, data.Session) return nil, fmt.Errorf("ipleak.net session mismatch: expected %s, got %s", session, data.Session)
} }