Multi options filters, fixes #231 (#262)

* OWNED environment variable for Mullvad
* CSV are now accepted for all servers filtering environment variables
This commit is contained in:
Quentin McGaw
2020-10-18 17:15:42 -04:00
committed by GitHub
parent c932f48a95
commit af606463ea
26 changed files with 247 additions and 223 deletions

View File

@@ -3,6 +3,7 @@ package provider
import (
"context"
"math/rand"
"strings"
"time"
"github.com/qdm12/gluetun/internal/models"
@@ -35,3 +36,19 @@ func tryUntilSuccessful(ctx context.Context, logger logging.Logger, fn func() er
func pickRandomConnection(connections []models.OpenVPNConnection, source rand.Source) models.OpenVPNConnection {
return connections[rand.New(source).Intn(len(connections))] //nolint:gosec
}
func filterByPossibilities(value string, possibilities []string) (filtered bool) {
if len(possibilities) == 0 {
return false
}
for _, possibility := range possibilities {
if strings.EqualFold(value, possibility) {
return false
}
}
return true
}
func commaJoin(slice []string) string {
return strings.Join(slice, ",")
}