From eaac8a3918fa4859532c11764c73c8ac4e298213 Mon Sep 17 00:00:00 2001 From: Markus Stenberg Date: Thu, 31 Oct 2024 07:52:20 +0200 Subject: [PATCH] Convert ignoredStreamKeys to a map --- data/config.go | 2 +- data/db.go | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/data/config.go b/data/config.go index e87c083..f64b321 100644 --- a/data/config.go +++ b/data/config.go @@ -12,4 +12,4 @@ package data // When adding rules, these stream keys are NOT included // // (This doesn't prevent their manual addition) -var ignoredStreamKeys = []string{"host", "lixie"} +var ignoredStreamKeys = map[string]bool{"host": true, "lixie": true} diff --git a/data/db.go b/data/db.go index 87f0ea1..e447b9b 100644 --- a/data/db.go +++ b/data/db.go @@ -184,17 +184,14 @@ func (self *Database) ClassifyHash(hash uint64, ham bool) error { Value: l.Message, }}} for _, k := range l.StreamKeys { - for _, ignoredStream := range ignoredStreamKeys { - if ignoredStream == k { - goto next - } + if ignoredStreamKeys[k] { + continue } rule.Matchers = append(rule.Matchers, LogFieldMatcher{ Field: k, Op: "=", Value: l.Stream[k], }) - next: } return self.Add(rule) }