72 lines
1.6 KiB
Go
72 lines
1.6 KiB
Go
package privatevpn
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/qdm12/gluetun/internal/configuration"
|
|
"github.com/qdm12/gluetun/internal/constants"
|
|
"github.com/qdm12/gluetun/internal/models"
|
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
|
)
|
|
|
|
func (p *Privatevpn) BuildConf(connection models.OpenVPNConnection,
|
|
username string, settings configuration.OpenVPN) (lines []string) {
|
|
if settings.Cipher == "" {
|
|
settings.Cipher = constants.AES128gcm
|
|
}
|
|
|
|
if settings.Auth == "" {
|
|
settings.Auth = constants.SHA256
|
|
}
|
|
|
|
lines = []string{
|
|
"client",
|
|
"dev tun",
|
|
"nobind",
|
|
"persist-key",
|
|
"remote-cert-tls server",
|
|
"tls-exit",
|
|
|
|
// Privatevpn specific
|
|
"comp-lzo",
|
|
"tun-ipv6",
|
|
|
|
// Added constant values
|
|
"auth-nocache",
|
|
"mute-replay-warnings",
|
|
"pull-filter ignore \"auth-token\"", // prevent auth failed loops
|
|
"auth-retry nointeract",
|
|
"suppress-timestamps",
|
|
|
|
// Modified variables
|
|
"verb " + strconv.Itoa(settings.Verbosity),
|
|
"auth-user-pass " + constants.OpenVPNAuthConf,
|
|
connection.ProtoLine(),
|
|
connection.RemoteLine(),
|
|
"data-ciphers-fallback " + settings.Cipher,
|
|
"data-ciphers " + settings.Cipher,
|
|
"auth " + settings.Auth,
|
|
}
|
|
|
|
if connection.Protocol == constants.UDP {
|
|
lines = append(lines, "key-direction 1")
|
|
}
|
|
|
|
if !settings.Root {
|
|
lines = append(lines, "user "+username)
|
|
}
|
|
|
|
if settings.MSSFix > 0 {
|
|
lines = append(lines, "mssfix "+strconv.Itoa(int(settings.MSSFix)))
|
|
}
|
|
|
|
lines = append(lines, utils.WrapOpenvpnCA(
|
|
constants.PrivatevpnCertificate)...)
|
|
lines = append(lines, utils.WrapOpenvpnTLSCrypt(
|
|
constants.PrivatevpnOpenvpnStaticKeyV1)...)
|
|
|
|
lines = append(lines, "")
|
|
|
|
return lines
|
|
}
|