Skip to content

Commit

Permalink
Merge pull request #863 from prometheus/superq/fix_ip_hash
Browse files Browse the repository at this point in the history
Fix IP hash
  • Loading branch information
SuperQ committed Jan 26, 2022
2 parents dc0f394 + 3383091 commit 8e18cb1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion prober/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

0 comments on commit 8e18cb1

Please sign in to comment.