2021-05-11 17:10:51 +00:00
|
|
|
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",
|
|
|
|
|
|
|
|
|
|
// 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(),
|
|
|
|
|
"auth " + settings.Auth,
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-23 17:40:14 +00:00
|
|
|
lines = append(lines, utils.CipherLines(settings.Cipher, settings.Version)...)
|
|
|
|
|
|
2021-05-11 17:10:51 +00:00
|
|
|
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)))
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-17 15:44:11 +00:00
|
|
|
if settings.IPv6 {
|
2021-07-19 01:46:20 +00:00
|
|
|
lines = append(lines, "tun-ipv6")
|
|
|
|
|
} else {
|
|
|
|
|
lines = append(lines, `pull-filter ignore "route-ipv6"`)
|
|
|
|
|
lines = append(lines, `pull-filter ignore "ifconfig-ipv6"`)
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-11 17:10:51 +00:00
|
|
|
lines = append(lines, utils.WrapOpenvpnCA(
|
|
|
|
|
constants.PrivatevpnCertificate)...)
|
|
|
|
|
lines = append(lines, utils.WrapOpenvpnTLSCrypt(
|
|
|
|
|
constants.PrivatevpnOpenvpnStaticKeyV1)...)
|
|
|
|
|
|
|
|
|
|
lines = append(lines, "")
|
|
|
|
|
|
|
|
|
|
return lines
|
|
|
|
|
}
|