package configuration import ( "fmt" "github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/golibs/params" ) func (settings *Provider) protonvpnLines() (lines []string) { if len(settings.ServerSelection.Countries) > 0 { lines = append(lines, lastIndent+"Countries: "+commaJoin(settings.ServerSelection.Countries)) } if len(settings.ServerSelection.Regions) > 0 { lines = append(lines, lastIndent+"Regions: "+commaJoin(settings.ServerSelection.Regions)) } if len(settings.ServerSelection.Cities) > 0 { lines = append(lines, lastIndent+"Cities: "+commaJoin(settings.ServerSelection.Cities)) } if len(settings.ServerSelection.Names) > 0 { lines = append(lines, lastIndent+"Names: "+commaJoin(settings.ServerSelection.Names)) } if len(settings.ServerSelection.Hostnames) > 0 { lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames)) } if settings.ServerSelection.FreeOnly { lines = append(lines, lastIndent+"Free only: yes") } return lines } func (settings *Provider) readProtonvpn(r reader) (err error) { settings.Name = constants.Protonvpn settings.ServerSelection.TCP, err = readProtocol(r.env) if err != nil { return err } settings.ServerSelection.TargetIP, err = readTargetIP(r.env) if err != nil { return err } settings.ServerSelection.CustomPort, err = readPortOrZero(r.env, "PORT") if err != nil { return fmt.Errorf("environment variable PORT: %w", err) } settings.ServerSelection.Countries, err = r.env.CSVInside("COUNTRY", constants.ProtonvpnCountryChoices()) if err != nil { return fmt.Errorf("environment variable COUNTRY: %w", err) } settings.ServerSelection.Regions, err = r.env.CSVInside("REGION", constants.ProtonvpnRegionChoices()) if err != nil { return fmt.Errorf("environment variable REGION: %w", err) } settings.ServerSelection.Cities, err = r.env.CSVInside("CITY", constants.ProtonvpnCityChoices()) if err != nil { return fmt.Errorf("environment variable CITY: %w", err) } settings.ServerSelection.Names, err = r.env.CSVInside("SERVER_NAME", constants.ProtonvpnNameChoices()) if err != nil { return fmt.Errorf("environment variable SERVER_NAME: %w", err) } settings.ServerSelection.Hostnames, err = r.env.CSVInside("SERVER_HOSTNAME", constants.ProtonvpnHostnameChoices()) if err != nil { return fmt.Errorf("environment variable SERVER_HOSTNAME: %w", err) } settings.ServerSelection.FreeOnly, err = r.env.YesNo("FREE_ONLY", params.Default("no")) if err != nil { return fmt.Errorf("environment variable FREE_ONLY: %w", err) } return nil }