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:
@@ -73,7 +73,7 @@ func (c *Cyberghost) BuildConf(connection models.Connection,
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.CyberghostCertificate)...)
|
||||
constants.CyberghostCA)...)
|
||||
|
||||
certData, err := parse.ExtractCert([]byte(*settings.ClientCrt))
|
||||
if err != nil {
|
||||
|
||||
@@ -78,7 +78,7 @@ func (p *Provider) BuildConf(connection models.Connection,
|
||||
lines = append(lines, utils.WrapOpenvpnRSAKey(
|
||||
constants.ExpressvpnRSAKey)...)
|
||||
lines = append(lines, utils.WrapOpenvpnTLSAuth(
|
||||
constants.ExpressvpnTLSAuthOpenvpnStaticKeyV1)...)
|
||||
constants.ExpressvpnTLSAuth)...)
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.ExpressvpnCA)...)
|
||||
|
||||
|
||||
@@ -73,9 +73,9 @@ func (f *Fastestvpn) BuildConf(connection models.Connection,
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.FastestvpnCertificate)...)
|
||||
constants.FastestvpnCA)...)
|
||||
lines = append(lines, utils.WrapOpenvpnTLSAuth(
|
||||
constants.FastestvpnOpenvpnStaticKeyV1)...)
|
||||
constants.FastestvpnTLSAuth)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -67,9 +67,9 @@ func (h *HideMyAss) BuildConf(connection models.Connection,
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.HideMyAssCA)...)
|
||||
lines = append(lines, utils.WrapOpenvpnCert(
|
||||
constants.HideMyAssCertificate)...)
|
||||
constants.HideMyAssCert)...)
|
||||
lines = append(lines, utils.WrapOpenvpnRSAKey(
|
||||
constants.HideMyAssRSAPrivateKey)...)
|
||||
constants.HideMyAssRSAKey)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ func (i *Ivpn) BuildConf(connection models.Connection,
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.IvpnCA)...)
|
||||
lines = append(lines, utils.WrapOpenvpnTLSAuth(
|
||||
constants.IvpnOpenvpnStaticKeyV1)...)
|
||||
constants.IvpnTLSAuth)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ func (m *Mullvad) BuildConf(connection models.Connection,
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.MullvadCertificate)...)
|
||||
constants.MullvadCA)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -74,9 +74,9 @@ func (n *Nordvpn) BuildConf(connection models.Connection,
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.NordvpnCertificate)...)
|
||||
constants.NordvpnCA)...)
|
||||
lines = append(lines, utils.WrapOpenvpnTLSAuth(
|
||||
constants.NordvpnOpenvpnStaticKeyV1)...)
|
||||
constants.NordvpnTLSAuth)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -80,9 +80,9 @@ func (p *Perfectprivacy) BuildConf(connection models.Connection,
|
||||
lines = append(lines, utils.WrapOpenvpnCert(
|
||||
constants.PerfectprivacyCert)...)
|
||||
lines = append(lines, utils.WrapOpenvpnKey(
|
||||
constants.PerfectprivacyPrivateKey)...)
|
||||
constants.PerfectprivacyKey)...)
|
||||
lines = append(lines, utils.WrapOpenvpnTLSCrypt(
|
||||
constants.PerfectprivacyTLSCryptOpenvpnStaticKeyV1)...)
|
||||
constants.PerfectprivacyTLSCrypt)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ func (p *Privado) BuildConf(connection models.Connection,
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.PrivadoCertificate)...)
|
||||
constants.PrivadoCA)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -67,9 +67,9 @@ func (p *Privatevpn) BuildConf(connection models.Connection,
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.PrivatevpnCertificate)...)
|
||||
constants.PrivatevpnCA)...)
|
||||
lines = append(lines, utils.WrapOpenvpnTLSAuth(
|
||||
constants.PrivatevpnOpenvpnStaticKeyV1)...)
|
||||
constants.PrivatevpnTLSAuth)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -73,9 +73,9 @@ func (p *Protonvpn) BuildConf(connection models.Connection,
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.ProtonvpnCertificate)...)
|
||||
constants.ProtonvpnCA)...)
|
||||
lines = append(lines, utils.WrapOpenvpnTLSAuth(
|
||||
constants.ProtonvpnOpenvpnStaticKeyV1)...)
|
||||
constants.ProtonvpnTLSAuth)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -66,13 +66,13 @@ func (p *Purevpn) BuildConf(connection models.Connection,
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.PurevpnCertificateAuthority)...)
|
||||
constants.PurevpnCA)...)
|
||||
lines = append(lines, utils.WrapOpenvpnCert(
|
||||
constants.PurevpnCertificate)...)
|
||||
constants.PurevpnCert)...)
|
||||
lines = append(lines, utils.WrapOpenvpnKey(
|
||||
constants.PurevpnKey)...)
|
||||
lines = append(lines, utils.WrapOpenvpnTLSAuth(
|
||||
constants.PurevpnOpenvpnStaticKeyV1)...)
|
||||
constants.PurevpnTLSAuth)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -73,9 +73,9 @@ func (s *Surfshark) BuildConf(connection models.Connection,
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.SurfsharkCertificate)...)
|
||||
constants.SurfsharkCA)...)
|
||||
lines = append(lines, utils.WrapOpenvpnTLSAuth(
|
||||
constants.SurfsharkOpenvpnStaticKeyV1)...)
|
||||
constants.SurfsharkTLSAuth)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@ func (t *Torguard) BuildConf(connection models.Connection,
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.TorguardCertificate)...)
|
||||
constants.TorguardCA)...)
|
||||
lines = append(lines, utils.WrapOpenvpnTLSAuth(
|
||||
constants.TorguardOpenvpnStaticKeyV1)...)
|
||||
constants.TorguardTLSAuth)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ func (p *Provider) BuildConf(connection models.Connection,
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.VPNUnlimitedCertificateAuthority)...)
|
||||
constants.VPNUnlimitedCA)...)
|
||||
|
||||
certData, err := parse.ExtractCert([]byte(*settings.ClientCrt))
|
||||
if err != nil {
|
||||
|
||||
@@ -65,7 +65,7 @@ func (v *Vyprvpn) BuildConf(connection models.Connection,
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.VyprvpnCertificate)...)
|
||||
constants.VyprvpnCA)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -81,9 +81,9 @@ func (w *Wevpn) BuildConf(connection models.Connection,
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.WevpnCA)...)
|
||||
lines = append(lines, utils.WrapOpenvpnCert(
|
||||
constants.WevpnCertificate)...)
|
||||
constants.WevpnCert)...)
|
||||
lines = append(lines, utils.WrapOpenvpnTLSCrypt(
|
||||
constants.WevpnOpenvpnStaticKeyV1)...)
|
||||
constants.WevpnTLSCrypt)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
@@ -74,9 +74,9 @@ func (w *Windscribe) BuildConf(connection models.Connection,
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.WindscribeCertificate)...)
|
||||
constants.WindscribeCA)...)
|
||||
lines = append(lines, utils.WrapOpenvpnTLSAuth(
|
||||
constants.WindscribeOpenvpnStaticKeyV1)...)
|
||||
constants.WindscribeTLSAuth)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user