mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-07 04:20:12 +02:00
chore(settings): OpenVPN ClientCrt -> Cert
This commit is contained in:
@@ -41,11 +41,11 @@ type OpenVPN struct {
|
||||
// It cannot be nil in the internal state.
|
||||
// It is ignored if it is set to the empty string.
|
||||
Auth *string
|
||||
// ClientCrt is the OpenVPN client certificate.
|
||||
// Cert is the OpenVPN certificate for the <cert> block.
|
||||
// This is notably used by Cyberghost.
|
||||
// It can be set to the empty string to be ignored.
|
||||
// It cannot be nil in the internal state.
|
||||
ClientCrt *string
|
||||
Cert *string
|
||||
// Key is the OpenVPN key.
|
||||
// This is used by Cyberghost and VPN Unlimited.
|
||||
// It can be set to the empty string to be ignored.
|
||||
@@ -106,7 +106,7 @@ func (o OpenVPN) validate(vpnProvider string) (err error) {
|
||||
return fmt.Errorf("custom configuration file: %w", err)
|
||||
}
|
||||
|
||||
err = validateOpenVPNClientCertificate(vpnProvider, *o.ClientCrt)
|
||||
err = validateOpenVPNClientCertificate(vpnProvider, *o.Cert)
|
||||
if err != nil {
|
||||
return fmt.Errorf("client certificate: %w", err)
|
||||
}
|
||||
@@ -211,7 +211,7 @@ func (o *OpenVPN) copy() (copied OpenVPN) {
|
||||
ConfFile: helpers.CopyStringPtr(o.ConfFile),
|
||||
Ciphers: helpers.CopyStringSlice(o.Ciphers),
|
||||
Auth: helpers.CopyStringPtr(o.Auth),
|
||||
ClientCrt: helpers.CopyStringPtr(o.ClientCrt),
|
||||
Cert: helpers.CopyStringPtr(o.Cert),
|
||||
Key: helpers.CopyStringPtr(o.Key),
|
||||
PIAEncPreset: helpers.CopyStringPtr(o.PIAEncPreset),
|
||||
IPv6: helpers.CopyBoolPtr(o.IPv6),
|
||||
@@ -232,7 +232,7 @@ func (o *OpenVPN) mergeWith(other OpenVPN) {
|
||||
o.ConfFile = helpers.MergeWithStringPtr(o.ConfFile, other.ConfFile)
|
||||
o.Ciphers = helpers.MergeStringSlices(o.Ciphers, other.Ciphers)
|
||||
o.Auth = helpers.MergeWithStringPtr(o.Auth, other.Auth)
|
||||
o.ClientCrt = helpers.MergeWithStringPtr(o.ClientCrt, other.ClientCrt)
|
||||
o.Cert = helpers.MergeWithStringPtr(o.Cert, other.Cert)
|
||||
o.Key = helpers.MergeWithStringPtr(o.Key, other.Key)
|
||||
o.PIAEncPreset = helpers.MergeWithStringPtr(o.PIAEncPreset, other.PIAEncPreset)
|
||||
o.IPv6 = helpers.MergeWithBool(o.IPv6, other.IPv6)
|
||||
@@ -253,7 +253,7 @@ func (o *OpenVPN) overrideWith(other OpenVPN) {
|
||||
o.ConfFile = helpers.OverrideWithStringPtr(o.ConfFile, other.ConfFile)
|
||||
o.Ciphers = helpers.OverrideWithStringSlice(o.Ciphers, other.Ciphers)
|
||||
o.Auth = helpers.OverrideWithStringPtr(o.Auth, other.Auth)
|
||||
o.ClientCrt = helpers.OverrideWithStringPtr(o.ClientCrt, other.ClientCrt)
|
||||
o.Cert = helpers.OverrideWithStringPtr(o.Cert, other.Cert)
|
||||
o.Key = helpers.OverrideWithStringPtr(o.Key, other.Key)
|
||||
o.PIAEncPreset = helpers.OverrideWithStringPtr(o.PIAEncPreset, other.PIAEncPreset)
|
||||
o.IPv6 = helpers.OverrideWithBool(o.IPv6, other.IPv6)
|
||||
@@ -275,7 +275,7 @@ func (o *OpenVPN) setDefaults(vpnProvider string) {
|
||||
|
||||
o.ConfFile = helpers.DefaultStringPtr(o.ConfFile, "")
|
||||
o.Auth = helpers.DefaultStringPtr(o.Auth, "")
|
||||
o.ClientCrt = helpers.DefaultStringPtr(o.ClientCrt, "")
|
||||
o.Cert = helpers.DefaultStringPtr(o.Cert, "")
|
||||
o.Key = helpers.DefaultStringPtr(o.Key, "")
|
||||
|
||||
var defaultEncPreset string
|
||||
@@ -313,8 +313,8 @@ func (o OpenVPN) toLinesNode() (node *gotree.Node) {
|
||||
node.Appendf("Auth: %s", *o.Auth)
|
||||
}
|
||||
|
||||
if *o.ClientCrt != "" {
|
||||
node.Appendf("Client crt: %s", helpers.ObfuscateData(*o.ClientCrt))
|
||||
if *o.Cert != "" {
|
||||
node.Appendf("Client crt: %s", helpers.ObfuscateData(*o.Cert))
|
||||
}
|
||||
|
||||
if *o.Key != "" {
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ func (r *Reader) readOpenVPN() (
|
||||
openVPN.Auth = &auth
|
||||
}
|
||||
|
||||
openVPN.ClientCrt, err = readBase64OrNil("OPENVPN_CERT")
|
||||
openVPN.Cert, err = readBase64OrNil("OPENVPN_CERT")
|
||||
if err != nil {
|
||||
return openVPN, fmt.Errorf("environment variable OPENVPN_CERT: %w", err)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ func (r *Reader) readOpenVPN() (settings settings.OpenVPN, err error) {
|
||||
return settings, fmt.Errorf("client key: %w", err)
|
||||
}
|
||||
|
||||
settings.ClientCrt, err = ReadFromFile(OpenVPNClientCertificatePath)
|
||||
settings.Cert, err = ReadFromFile(OpenVPNClientCertificatePath)
|
||||
if err != nil {
|
||||
return settings, fmt.Errorf("client certificate: %w", err)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func readOpenVPN() (
|
||||
return settings, fmt.Errorf("cannot read client key file: %w", err)
|
||||
}
|
||||
|
||||
settings.ClientCrt, err = readSecretFileAsStringPtr(
|
||||
settings.Cert, err = readSecretFileAsStringPtr(
|
||||
"OPENVPN_CLIENTCRT_SECRETFILE",
|
||||
"/run/secrets/openvpn_clientcrt",
|
||||
)
|
||||
|
||||
@@ -189,9 +189,9 @@ func OpenVPNConfig(provider OpenVPNProviderSettings,
|
||||
lines.addLines(WrapOpenvpnTLSCrypt(provider.TLSCrypt))
|
||||
}
|
||||
|
||||
if *settings.ClientCrt != "" {
|
||||
certData, err := extract.PEM([]byte(*settings.ClientCrt))
|
||||
panicOnError(err, "cannot extract client crt")
|
||||
if *settings.Cert != "" {
|
||||
certData, err := extract.PEM([]byte(*settings.Cert))
|
||||
panicOnError(err, "cannot extract OpenVPN certificate")
|
||||
lines.addLines(WrapOpenvpnCert(certData))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user