Skip to content
Snippets Groups Projects
Commit 641c4311 authored by ale's avatar ale
Browse files

Support an allow list for the 'classified' plugin

parent 993bd467
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ import (
type classifiedPlugin struct {
counters *DecayCounterMap
limit uint64
allow util.StringSet
}
func newClassifiedPlugin() *classifiedPlugin {
......@@ -38,6 +39,14 @@ func (p *classifiedPlugin) Init(config map[string]interface{}, db *bolt.DB) erro
p.limit = uint64(i)
}
if f, ok := config["classified_allow_list"].(string); ok && f != "" {
wl, err := util.ReadStringSetFromFile(f)
if err != nil {
return err
}
p.allow = wl
}
return nil
}
......@@ -48,6 +57,11 @@ func (p *classifiedPlugin) Test(ctx context.Context, comment *nospam.Comment) (f
}
for domain := range tlds {
if p.allow != nil {
if _, ok := p.allow.HasPrefix(domain); ok {
continue
}
}
value, err := p.counters.Get(domain)
if err != nil {
continue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment