Skip to content

Commit

Permalink
hotfix(pia): allow one value in SERVER_NAMES for the custom provider
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jun 17, 2024
1 parent 4218dba commit 93ed87d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/configuration/settings/serverselection.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (ss *ServerSelection) validate(vpnServiceProvider string,
*ss = surfsharkRetroRegion(*ss)
}

err = validateServerFilters(*ss, filterChoices)
err = validateServerFilters(*ss, filterChoices, vpnServiceProvider)
if err != nil {
return fmt.Errorf("for VPN service provider %s: %w", vpnServiceProvider, err)
}
Expand Down Expand Up @@ -196,7 +196,8 @@ func getLocationFilterChoices(vpnServiceProvider string,

// validateServerFilters validates filters against the choices given as arguments.
// Set an argument to nil to pass the check for a particular filter.
func validateServerFilters(settings ServerSelection, filterChoices models.FilterChoices) (err error) {
func validateServerFilters(settings ServerSelection, filterChoices models.FilterChoices,
vpnServiceProvider string) (err error) {
err = validate.AreAllOneOfCaseInsensitive(settings.Countries, filterChoices.Countries)
if err != nil {
return fmt.Errorf("%w: %w", ErrCountryNotValid, err)
Expand All @@ -222,6 +223,12 @@ func validateServerFilters(settings ServerSelection, filterChoices models.Filter
return fmt.Errorf("%w: %w", ErrHostnameNotValid, err)
}

if vpnServiceProvider == providers.Custom && len(settings.Names) == 1 {
// Allow a single name to be specified for the custom provider in case
// the user wants to use VPN server side port forwarding with PIA
// which requires a server name for TLS verification.
filterChoices.Names = settings.Names
}
err = validate.AreAllOneOfCaseInsensitive(settings.Names, filterChoices.Names)
if err != nil {
return fmt.Errorf("%w: %w", ErrNameNotValid, err)
Expand Down

0 comments on commit 93ed87d

Please sign in to comment.