OPENVPN_CIPHER variable (#100), refers to #94 and #59

This commit is contained in:
Quentin McGaw
2020-03-26 20:29:32 -04:00
committed by GitHub
parent d534f92432
commit 15a549be11
9 changed files with 37 additions and 11 deletions

View File

@@ -66,15 +66,19 @@ func (c *configurator) GetOpenVPNConnections(region models.PIARegion, protocol m
return connections, nil
}
func (c *configurator) BuildConf(connections []models.OpenVPNConnection, encryption models.PIAEncryption, verbosity, uid, gid int, root bool) (err error) {
var X509CRL, certificate, cipherAlgo, authAlgo string
func (c *configurator) BuildConf(connections []models.OpenVPNConnection, encryption models.PIAEncryption, verbosity, uid, gid int, root bool, cipher string) (err error) {
var X509CRL, certificate, authAlgo string
if encryption == constants.PIAEncryptionNormal {
cipherAlgo = "aes-128-cbc"
if len(cipher) == 0 {
cipher = "aes-128-cbc"
}
authAlgo = "sha1"
X509CRL = constants.PIAX509CRL_NORMAL
certificate = constants.PIACertificate_NORMAL
} else { // strong encryption
cipherAlgo = "aes-256-cbc"
if len(cipher) == 0 {
cipher = "aes-256-cbc"
}
authAlgo = "sha256"
X509CRL = constants.PIAX509CRL_STRONG
certificate = constants.PIACertificate_STRONG
@@ -104,9 +108,12 @@ func (c *configurator) BuildConf(connections []models.OpenVPNConnection, encrypt
fmt.Sprintf("verb %d", verbosity),
fmt.Sprintf("auth-user-pass %s", constants.OpenVPNAuthConf),
fmt.Sprintf("proto %s", string(connections[0].Protocol)),
fmt.Sprintf("cipher %s", cipherAlgo),
fmt.Sprintf("cipher %s", cipher),
fmt.Sprintf("auth %s", authAlgo),
}
if strings.HasSuffix(cipher, "-gcm") {
lines = append(lines, "ncp-disable")
}
if !root {
lines = append(lines, "user nonrootuser")
}

View File

@@ -18,7 +18,7 @@ const logPrefix = "PIA configurator"
type Configurator interface {
GetOpenVPNConnections(region models.PIARegion, protocol models.NetworkProtocol,
encryption models.PIAEncryption, targetIP net.IP) (connections []models.OpenVPNConnection, err error)
BuildConf(connections []models.OpenVPNConnection, encryption models.PIAEncryption, verbosity, uid, gid int, root bool) (err error)
BuildConf(connections []models.OpenVPNConnection, encryption models.PIAEncryption, verbosity, uid, gid int, root bool, cipher string) (err error)
GetPortForward() (port uint16, err error)
WritePortForward(filepath models.Filepath, port uint16) (err error)
AllowPortForwardFirewall(device models.VPNDevice, port uint16) (err error)