skipping duplicates whitelist inserts
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9dbe473cb7
commit
4f66f6fddd
@ -25,6 +25,11 @@ func (wl Whitelist) Insert(cfg config.Config) (err error) {
|
|||||||
exists, _ := cfg.Db.Get(&w)
|
exists, _ := cfg.Db.Get(&w)
|
||||||
if exists {
|
if exists {
|
||||||
existing, _ := GetWhitelists(cfg)
|
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)
|
existing = append(existing, wl.IP)
|
||||||
w.Value = strings.Join(existing, ",")
|
w.Value = strings.Join(existing, ",")
|
||||||
cfg.Db.ID(w.ID).Update(&w)
|
cfg.Db.ID(w.ID).Update(&w)
|
||||||
|
Loading…
Reference in New Issue
Block a user