diff --git a/transformers/latency.go b/transformers/latency.go index 926a6e68..3ca1e4bc 100644 --- a/transformers/latency.go +++ b/transformers/latency.go @@ -27,6 +27,10 @@ func NewMapQueries(ttl time.Duration, channels []chan dnsutils.DnsMessage) MapQu } } +func (mp *MapQueries) SetTtl(ttl time.Duration) { + mp.ttl = ttl +} + func (mp *MapQueries) Exists(key uint64) (ok bool) { mp.RLock() defer mp.RUnlock() @@ -69,6 +73,10 @@ func NewHashQueries(ttl time.Duration) HashQueries { } } +func (mp *HashQueries) SetTtl(ttl time.Duration) { + mp.ttl = ttl +} + func (mp *HashQueries) Get(key uint64) (value int64, ok bool) { mp.RLock() defer mp.RUnlock() @@ -124,6 +132,13 @@ func NewLatencySubprocessor(config *dnsutils.ConfigTransformers, logger *logger. return &s } +func (s *LatencyProcessor) ReloadConfig(config *dnsutils.ConfigTransformers) { + s.config = config + + s.hashQueries.SetTtl(time.Duration(config.Latency.QueriesTimeout) * time.Second) + s.mapQueries.SetTtl(time.Duration(config.Latency.QueriesTimeout) * time.Second) +} + func (s *LatencyProcessor) MeasureLatency(dm *dnsutils.DnsMessage) { queryport, _ := strconv.Atoi(dm.NetworkInfo.QueryPort) if len(dm.NetworkInfo.QueryIp) > 0 && queryport > 0 && !dm.DNS.MalformedPacket { diff --git a/transformers/subprocessors.go b/transformers/subprocessors.go index 0f240191..55b435c7 100644 --- a/transformers/subprocessors.go +++ b/transformers/subprocessors.go @@ -60,6 +60,9 @@ func (p *Transforms) ReloadConfig(config *dnsutils.ConfigTransformers) { p.NormalizeTransform.ReloadConfig(config) p.GeoipTransform.ReloadConfig(config) p.FilteringTransform.ReloadConfig(config) + p.UserPrivacyTransform.ReloadConfig(config) + p.LatencyTransform.ReloadConfig(config) + p.SuspiciousTransform.ReloadConfig(config) p.Prepare() } diff --git a/transformers/subprocessors_test.go b/transformers/subprocessors_test.go index 688d967d..69bf415f 100644 --- a/transformers/subprocessors_test.go +++ b/transformers/subprocessors_test.go @@ -274,6 +274,7 @@ func TestTransformAndFilter(t *testing.T) { config.UserPrivacy.AnonymizeIP = true // file contains google.fr, test.github.com + config.Filtering.Enable = true config.Filtering.KeepDomainFile = "../testsdata/filtering_keep_domains.txt" TEST_URL1 := "mail.google.com" diff --git a/transformers/suspicious.go b/transformers/suspicious.go index c22715ef..38482361 100644 --- a/transformers/suspicious.go +++ b/transformers/suspicious.go @@ -43,6 +43,15 @@ func NewSuspiciousSubprocessor(config *dnsutils.ConfigTransformers, logger *logg } func (p *SuspiciousTransform) ReadConfig() { + // cleanup maps + for key := range p.CommonQtypes { + delete(p.CommonQtypes, key) + } + for key := range p.whitelistDomainsRegex { + delete(p.whitelistDomainsRegex, key) + } + + // load maps for _, v := range p.config.Suspicious.CommonQtypes { p.CommonQtypes[v] = true } @@ -51,6 +60,12 @@ func (p *SuspiciousTransform) ReadConfig() { } } +func (s *SuspiciousTransform) ReloadConfig(config *dnsutils.ConfigTransformers) { + s.config = config + + s.ReadConfig() +} + func (p *SuspiciousTransform) IsEnabled() bool { return p.config.Suspicious.Enable } diff --git a/transformers/userprivacy.go b/transformers/userprivacy.go index efc4a823..4d0d22ad 100644 --- a/transformers/userprivacy.go +++ b/transformers/userprivacy.go @@ -43,6 +43,10 @@ func NewUserPrivacySubprocessor(config *dnsutils.ConfigTransformers, logger *log return s } +func (s *UserPrivacyProcessor) ReloadConfig(config *dnsutils.ConfigTransformers) { + s.config = config +} + func (s *UserPrivacyProcessor) MinimazeQname(qname string) string { if etpo, err := publicsuffix.EffectiveTLDPlusOne(qname); err == nil { return etpo