projects
/
blackbox_exporter.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
70bff79
)
Fix IP hash
author
SuperQ
<superq@gmail.com>
Sat, 22 Jan 2022 15:37:30 +0000
(16:37 +0100)
committer
SuperQ
<superq@gmail.com>
Sat, 22 Jan 2022 15:37:30 +0000
(16:37 +0100)
Select the correct slice of bytes to hash based on IPv4 or IPv6 address
family.
Signed-off-by: SuperQ <superq@gmail.com>
prober/utils.go
patch
|
blob
|
blame
|
history
diff --git
a/prober/utils.go
b/prober/utils.go
index 74fb41d87ed5ea7ded7de61c06c360d78f4092f5..52f9f343f4ab21c364644ecf25e8db6dc564ac64 100644
(file)
--- 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())
}