42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package params
|
|
|
|
import (
|
|
"strings"
|
|
|
|
libparams "github.com/qdm12/golibs/params"
|
|
"github.com/qdm12/private-internet-access-docker/internal/constants"
|
|
)
|
|
|
|
// GetCyberghostGroup obtains the server group for the Cyberghost server from the
|
|
// environment variable CYBERGHOST_GROUP
|
|
func (p *reader) GetCyberghostGroup() (group string, err error) {
|
|
s, err := p.envParams.GetValueIfInside("CYBERGHOST_GROUP", constants.CyberghostGroupChoices())
|
|
return s, err
|
|
}
|
|
|
|
// GetCyberghostRegion obtains the country name for the Cyberghost server from the
|
|
// environment variable REGION
|
|
func (p *reader) GetCyberghostRegion() (region string, err error) {
|
|
s, err := p.envParams.GetValueIfInside("REGION", constants.CyberghostRegionChoices())
|
|
return s, err
|
|
}
|
|
|
|
// GetCyberghostClientKey obtains the one line client key to use for openvpn from the
|
|
// environment variable CLIENT_KEY
|
|
func (p *reader) GetCyberghostClientKey() (clientKey string, err error) {
|
|
clientKey, err = p.envParams.GetEnv("CLIENT_KEY", libparams.CaseSensitiveValue())
|
|
if err != nil {
|
|
return "", err
|
|
} else if len(clientKey) > 0 {
|
|
return clientKey, nil
|
|
}
|
|
content, err := p.fileManager.ReadFile("/files/client.key")
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
s := string(content)
|
|
s = strings.ReplaceAll(s, "\n", "")
|
|
s = strings.ReplaceAll(s, "\r", "")
|
|
return s, nil
|
|
}
|