- Paves the way for Wireguard - VPN struct contains Type, Openvpn and Provider configurations - OpenVPN specific options (e.g. client key) moved from Provider to Openvpn configuration struct - Move Provider configuration from OpenVPN configuration to VPN - HTTP control server returns only openvpn settings (not provider settings)
85 lines
1.9 KiB
Go
85 lines
1.9 KiB
Go
package protonvpn
|
|
|
|
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 *Protonvpn) BuildConf(connection models.OpenVPNConnection,
|
|
username string, settings configuration.OpenVPN) (lines []string) {
|
|
if settings.Cipher == "" {
|
|
settings.Cipher = constants.AES256cbc
|
|
}
|
|
|
|
if settings.Auth == "" {
|
|
settings.Auth = constants.SHA512
|
|
}
|
|
|
|
const defaultMSSFix = 1450
|
|
if settings.MSSFix == 0 {
|
|
settings.MSSFix = defaultMSSFix
|
|
}
|
|
|
|
lines = []string{
|
|
"client",
|
|
"dev tun",
|
|
"nobind",
|
|
"persist-key",
|
|
"remote-cert-tls server",
|
|
"tls-exit",
|
|
|
|
// Protonvpn specific
|
|
"tun-mtu 1500",
|
|
"tun-mtu-extra 32",
|
|
"mssfix " + strconv.Itoa(int(settings.MSSFix)),
|
|
"reneg-sec 0",
|
|
"key-direction 1",
|
|
"pull",
|
|
"comp-lzo no",
|
|
|
|
// 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,
|
|
}
|
|
|
|
lines = append(lines, utils.CipherLines(settings.Cipher, settings.Version)...)
|
|
|
|
if connection.Protocol == constants.UDP {
|
|
lines = append(lines, "fast-io")
|
|
}
|
|
|
|
if !settings.Root {
|
|
lines = append(lines, "user "+username)
|
|
}
|
|
|
|
if settings.IPv6 {
|
|
lines = append(lines, "tun-ipv6")
|
|
} else {
|
|
lines = append(lines, `pull-filter ignore "route-ipv6"`)
|
|
lines = append(lines, `pull-filter ignore "ifconfig-ipv6"`)
|
|
}
|
|
|
|
lines = append(lines, utils.WrapOpenvpnCA(
|
|
constants.ProtonvpnCertificate)...)
|
|
lines = append(lines, utils.WrapOpenvpnTLSAuth(
|
|
constants.ProtonvpnOpenvpnStaticKeyV1)...)
|
|
|
|
lines = append(lines, "")
|
|
|
|
return lines
|
|
}
|