2021-02-06 11:05:50 -05:00
|
|
|
package configuration
|
|
|
|
|
|
|
|
|
|
import (
|
2021-07-23 02:34:15 +00:00
|
|
|
"fmt"
|
|
|
|
|
|
2021-02-06 11:05:50 -05:00
|
|
|
"github.com/qdm12/gluetun/internal/constants"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func (settings *Provider) privadoLines() (lines []string) {
|
2021-05-09 00:51:34 +00:00
|
|
|
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))
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-06 11:05:50 -05:00
|
|
|
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
|
|
|
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-17 16:54:22 +00:00
|
|
|
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
|
|
|
|
|
2021-02-06 11:05:50 -05:00
|
|
|
return lines
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (settings *Provider) readPrivado(r reader) (err error) {
|
|
|
|
|
settings.Name = constants.Privado
|
|
|
|
|
|
|
|
|
|
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-09 00:51:34 +00:00
|
|
|
settings.ServerSelection.Countries, err = r.env.CSVInside("COUNTRY", constants.PrivadoCountryChoices())
|
|
|
|
|
if err != nil {
|
2021-07-23 02:34:15 +00:00
|
|
|
return fmt.Errorf("environment variable COUNTRY: %w", err)
|
2021-05-09 00:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
settings.ServerSelection.Regions, err = r.env.CSVInside("REGION", constants.PrivadoRegionChoices())
|
|
|
|
|
if err != nil {
|
2021-07-23 02:34:15 +00:00
|
|
|
return fmt.Errorf("environment variable REGION: %w", err)
|
2021-05-09 00:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
settings.ServerSelection.Cities, err = r.env.CSVInside("CITY", constants.PrivadoCityChoices())
|
|
|
|
|
if err != nil {
|
2021-07-23 02:34:15 +00:00
|
|
|
return fmt.Errorf("environment variable CITY: %w", err)
|
2021-05-09 00:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
2021-02-14 16:40:48 +00:00
|
|
|
settings.ServerSelection.Hostnames, err = r.env.CSVInside("SERVER_HOSTNAME", constants.PrivadoHostnameChoices())
|
2021-02-06 11:05:50 -05:00
|
|
|
if err != nil {
|
2021-07-23 02:34:15 +00:00
|
|
|
return fmt.Errorf("environment variable SERVER_HOSTNAME: %w", err)
|
2021-02-06 11:05:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|