feat(config): allow invalid server filters (#2419)

- Disallow setting a server filter when there is no choice available
- Allow setting an invalid server filter when there is at least one choice available
- Log at warn level when an invalid server filter is set
- Fix #2337
This commit is contained in:
Quentin McGaw
2024-08-17 12:01:26 +02:00
committed by GitHub
parent 4a128677dd
commit 897a9d7f57
8 changed files with 68 additions and 26 deletions

View File

@@ -25,7 +25,7 @@ type Provider struct {
}
// TODO v4 remove pointer for receiver (because of Surfshark).
func (p *Provider) validate(vpnType string, storage Storage) (err error) {
func (p *Provider) validate(vpnType string, storage Storage, warner Warner) (err error) {
// Validate Name
var validNames []string
if vpnType == vpn.OpenVPN {
@@ -48,7 +48,7 @@ func (p *Provider) validate(vpnType string, storage Storage) (err error) {
return fmt.Errorf("%w for Wireguard: %w", ErrVPNProviderNameNotValid, err)
}
err = p.ServerSelection.validate(p.Name, storage)
err = p.ServerSelection.validate(p.Name, storage, warner)
if err != nil {
return fmt.Errorf("server selection: %w", err)
}