From 5f54792eb6991cd84b9b7af68079265ad791a8dc Mon Sep 17 00:00:00 2001 From: Oliver Herms Date: Fri, 15 Jan 2021 13:11:57 +0100 Subject: [PATCH] Fix IP filtering --- pkg/frontend/frontend.go | 8 +++++++- pkg/servers/sflow/sfserver.go | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/frontend/frontend.go b/pkg/frontend/frontend.go index 7195291..dff6393 100644 --- a/pkg/frontend/frontend.go +++ b/pkg/frontend/frontend.go @@ -276,7 +276,13 @@ func (fe *Frontend) processQuery(r *http.Request) (*result, error) { case string: keyComponents = append(keyComponents, fmt.Sprintf("%s=%s", label, (*valuePtrs[i].(*interface{})).(string))) case net.IP: - keyComponents = append(keyComponents, fmt.Sprintf("%s=%s", label, (*valuePtrs[i].(*interface{})).(net.IP).String())) + addr := (*valuePtrs[i].(*interface{})).(net.IP) + if addr.To4() == nil { + keyComponents = append(keyComponents, fmt.Sprintf("%s=IPv6StringToNum(%s)", label, addr.String())) + } else { + keyComponents = append(keyComponents, fmt.Sprintf("%s=IPv4ToIPv6(IPv4StringToNum(%s))", label, addr.String())) + } + } } diff --git a/pkg/servers/sflow/sfserver.go b/pkg/servers/sflow/sfserver.go index d8e692f..c9c3dac 100644 --- a/pkg/servers/sflow/sfserver.go +++ b/pkg/servers/sflow/sfserver.go @@ -262,7 +262,6 @@ func (sfs *SflowServer) processPacket(agent bnet.IP, buffer []byte) { } if fl.IntIn == "" { - fl.IntIn += fmt.Sprintf("%d", fs.FlowSampleHeader.InputIf) }