middleware/clientapproval : add error when using blacklist and whitelist at the same time

This commit is contained in:
Pierre-Alain TORET 2018-09-20 10:12:35 +02:00
parent d5bddeac96
commit 12c9f95eb1

View file

@ -56,6 +56,10 @@ func NewHook(cfg Config) (middleware.Hook, error) {
unapproved: make(map[bittorrent.ClientID]struct{}), unapproved: make(map[bittorrent.ClientID]struct{}),
} }
if len(cfg.Whitelist) > 0 && len(cfg.Blacklist) > 0 {
return nil, fmt.Errorf("using both whitelist and blacklist is invalid")
}
for _, cidString := range cfg.Whitelist { for _, cidString := range cfg.Whitelist {
cidBytes := []byte(cidString) cidBytes := []byte(cidString)
if len(cidBytes) != 6 { if len(cidBytes) != 6 {