feat(openvpn): add support for openvpn 2.6

This commit is contained in:
Quentin McGaw
2023-05-21 13:23:51 +00:00
parent e8f2296a0d
commit 3b807e2ca9
8 changed files with 16 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ import (
// OpenVPN contains settings to configure the OpenVPN client.
type OpenVPN struct {
// Version is the OpenVPN version to run.
// It can only be "2.5".
// It can only be "2.5" or "2.6".
Version string
// User is the OpenVPN authentication username.
// It cannot be nil in the internal state if OpenVPN is used.
@@ -88,7 +88,7 @@ var ivpnAccountID = regexp.MustCompile(`^(i|ivpn)\-[a-zA-Z0-9]{4}\-[a-zA-Z0-9]{4
func (o OpenVPN) validate(vpnProvider string) (err error) {
// Validate version
validVersions := []string{openvpn.Openvpn25}
validVersions := []string{openvpn.Openvpn25, openvpn.Openvpn26}
if !helpers.IsOneOf(o.Version, validVersions...) {
return fmt.Errorf("%w: %q can only be one of %s",
ErrOpenVPNVersionIsNotValid, o.Version, strings.Join(validVersions, ", "))

View File

@@ -2,4 +2,5 @@ package openvpn
const (
Openvpn25 = "2.5"
Openvpn26 = "2.6"
)

View File

@@ -15,6 +15,7 @@ var ErrVersionUnknown = errors.New("OpenVPN version is unknown")
const (
binOpenvpn25 = "openvpn2.5"
binOpenvpn26 = "openvpn2.6"
)
func start(ctx context.Context, starter command.Starter, version string, flags []string) (
@@ -23,6 +24,8 @@ func start(ctx context.Context, starter command.Starter, version string, flags [
switch version {
case openvpn.Openvpn25:
bin = binOpenvpn25
case openvpn.Openvpn26:
bin = binOpenvpn26
default:
return nil, nil, nil, fmt.Errorf("%w: %s", ErrVersionUnknown, version)
}

View File

@@ -12,6 +12,10 @@ func (c *Configurator) Version25(ctx context.Context) (version string, err error
return c.version(ctx, binOpenvpn25)
}
func (c *Configurator) Version26(ctx context.Context) (version string, err error) {
return c.version(ctx, binOpenvpn26)
}
var ErrVersionTooShort = errors.New("version output is too short")
func (c *Configurator) version(ctx context.Context, binName string) (version string, err error) {

View File

@@ -24,7 +24,7 @@ func (p *Provider) OpenVPNConfig(connection models.Connection,
}
switch settings.Version {
case openvpn.Openvpn25:
case openvpn.Openvpn25, openvpn.Openvpn26:
providerSettings.Ciphers = []string{
openvpn.AES256gcm, openvpn.AES256cbc, openvpn.AES192gcm,
openvpn.AES192cbc, openvpn.AES128gcm, openvpn.AES128cbc,