chore(validation): move functions from constants
- Move validation functions from `internal/constants` to `internal/configuration/settings/validation` - Concatenate all OpenVPN constants in `internal/constants/openvpn.go`
This commit is contained in:
@@ -18,7 +18,7 @@ var (
|
||||
)
|
||||
|
||||
func newHTTPClient(serverName string) (client *http.Client, err error) {
|
||||
certificateBytes, err := base64.StdEncoding.DecodeString(constants.PIACertificateStrong)
|
||||
certificateBytes, err := base64.StdEncoding.DecodeString(constants.PiaCAStrong)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w: %s", ErrParseCertificate, err)
|
||||
}
|
||||
|
||||
@@ -17,17 +17,17 @@ func (p *PIA) BuildConf(connection models.Connection,
|
||||
defaultCipher = constants.AES128cbc
|
||||
defaultAuth = constants.SHA1
|
||||
X509CRL = constants.PiaX509CRLNormal
|
||||
certificate = constants.PIACertificateNormal
|
||||
certificate = constants.PiaCANormal
|
||||
case constants.PIAEncryptionPresetNone:
|
||||
defaultCipher = "none"
|
||||
defaultAuth = "none"
|
||||
X509CRL = constants.PiaX509CRLNormal
|
||||
certificate = constants.PIACertificateNormal
|
||||
certificate = constants.PiaCANormal
|
||||
default: // strong
|
||||
defaultCipher = constants.AES256cbc
|
||||
defaultAuth = constants.SHA256
|
||||
X509CRL = constants.PiaX509CRLStrong
|
||||
certificate = constants.PIACertificateStrong
|
||||
certificate = constants.PiaCAStrong
|
||||
}
|
||||
|
||||
if len(settings.Ciphers) == 0 {
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||
"github.com/qdm12/golibs/format"
|
||||
)
|
||||
@@ -33,7 +33,13 @@ var (
|
||||
func (p *PIA) PortForward(ctx context.Context, client *http.Client,
|
||||
logger utils.Logger, gateway net.IP, serverName string) (
|
||||
port uint16, err error) {
|
||||
server := constants.PIAServerWhereName(p.servers, serverName)
|
||||
var server models.PIAServer
|
||||
for _, server = range p.servers {
|
||||
if server.ServerName == serverName {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !server.PortForward {
|
||||
logger.Error("The server " + serverName +
|
||||
" (region " + server.Region + ") does not support port forwarding")
|
||||
|
||||
@@ -20,7 +20,7 @@ func Test_newHTTPClient(t *testing.T) {
|
||||
|
||||
const serverName = "testserver"
|
||||
|
||||
certificateBytes, err := base64.StdEncoding.DecodeString(constants.PIACertificateStrong)
|
||||
certificateBytes, err := base64.StdEncoding.DecodeString(constants.PiaCAStrong)
|
||||
require.NoError(t, err)
|
||||
certificate, err := x509.ParseCertificate(certificateBytes)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user