From 338309104e6c00fa6be6f27dcc05ee34c2e16b01 Mon Sep 17 00:00:00 2001 From: SuperQ Date: Sat, 22 Jan 2022 16:37:30 +0100 Subject: [PATCH] Fix IP hash Select the correct slice of bytes to hash based on IPv4 or IPv6 address family. Signed-off-by: SuperQ --- prober/utils.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/prober/utils.go b/prober/utils.go index 74fb41d..52f9f34 100644 --- a/prober/utils.go +++ b/prober/utils.go @@ -135,6 +135,10 @@ func chooseProtocol(ctx context.Context, IPProtocol string, fallbackIPProtocol b func ipHash(ip net.IP) float64 { h := fnv.New32a() - h.Write(ip) + if ip.To4() != nil { + h.Write(ip.To4()) + } else { + h.Write(ip.To16()) + } return float64(h.Sum32()) } -- 2.25.1