skipping duplicates whitelist inserts
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul Lecuq 2022-02-08 15:32:10 +01:00
parent 9dbe473cb7
commit 4f66f6fddd

View File

@ -25,6 +25,11 @@ func (wl Whitelist) Insert(cfg config.Config) (err error) {
exists, _ := cfg.Db.Get(&w)
if exists {
existing, _ := GetWhitelists(cfg)
for _, j := range existing {
if j == wl.IP {
return fmt.Errorf("ip %s already in config", j)
}
}
existing = append(existing, wl.IP)
w.Value = strings.Join(existing, ",")
cfg.Db.ID(w.ID).Update(&w)