Skip to content

Commit 037e85b

Browse files
committed
fix: sort DNS IPs for deterministic replay comparison
DNS round-robin returns IPs in varying order. Sorting ensures the response body matches between record and replay.
1 parent 9d4d63b commit 037e85b

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

dns-dedup/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net"
77
"net/http"
88
"os"
9+
"sort"
910
"strconv"
1011
"time"
1112
)
@@ -42,6 +43,7 @@ func main() {
4243
http.Error(w, err.Error(), http.StatusInternalServerError)
4344
return
4445
}
46+
sort.Strings(ips) // deterministic order for replay comparison
4547
w.Header().Set("Content-Type", "application/json")
4648
json.NewEncoder(w).Encode(map[string]interface{}{
4749
"domain": d,
@@ -77,6 +79,7 @@ func main() {
7779
if err != nil {
7880
results = append(results, result{Iteration: i, Error: err.Error()})
7981
} else {
82+
sort.Strings(ips) // deterministic order for replay comparison
8083
key := fmt.Sprintf("%v", ips)
8184
isNew := !seen[key]
8285
seen[key] = true

0 commit comments

Comments
 (0)