2021-10-05 10:44:15 -07:00
|
|
|
package perfectprivacy
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strconv"
|
|
|
|
|
|
2022-01-06 06:40:23 -05:00
|
|
|
"github.com/qdm12/gluetun/internal/configuration/settings"
|
2021-10-05 10:44:15 -07:00
|
|
|
"github.com/qdm12/gluetun/internal/constants"
|
|
|
|
|
"github.com/qdm12/gluetun/internal/models"
|
|
|
|
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func (p *Perfectprivacy) BuildConf(connection models.Connection,
|
2022-01-06 06:40:23 -05:00
|
|
|
settings settings.OpenVPN) (lines []string, err error) {
|
2021-10-05 20:36:23 +00:00
|
|
|
if len(settings.Ciphers) == 0 {
|
|
|
|
|
settings.Ciphers = []string{constants.AES256cbc, constants.AES256gcm}
|
2021-10-05 10:44:15 -07:00
|
|
|
}
|
|
|
|
|
|
2022-01-06 06:40:23 -05:00
|
|
|
auth := *settings.Auth
|
|
|
|
|
if auth == "" {
|
|
|
|
|
auth = constants.SHA512
|
2021-10-05 10:44:15 -07:00
|
|
|
}
|
|
|
|
|
|
2022-01-06 06:40:23 -05:00
|
|
|
mssFix := *settings.MSSFix
|
|
|
|
|
if mssFix == 0 {
|
|
|
|
|
mssFix = 1450
|
2021-10-05 10:44:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lines = []string{
|
|
|
|
|
"client",
|
|
|
|
|
"nobind",
|
|
|
|
|
"tls-exit",
|
|
|
|
|
"dev " + settings.Interface,
|
2022-01-06 06:40:23 -05:00
|
|
|
"verb " + strconv.Itoa(*settings.Verbosity),
|
2021-10-05 10:44:15 -07:00
|
|
|
|
|
|
|
|
// Perfect Privacy specific
|
|
|
|
|
"ping 5",
|
|
|
|
|
"tun-mtu 1500",
|
|
|
|
|
"tun-mtu-extra 32",
|
2022-01-06 06:40:23 -05:00
|
|
|
"mssfix " + strconv.Itoa(int(mssFix)),
|
2021-10-05 10:44:15 -07:00
|
|
|
"reneg-sec 3600",
|
|
|
|
|
"key-direction 1",
|
|
|
|
|
"tls-cipher TLS_CHACHA20_POLY1305_SHA256:TLS-DHE-RSA-WITH-AES-256-GCM-SHA384:TLS-DHE-RSA-WITH-AES-256-CBC-SHA:TLS-DHE-RSA-WITH-AES-128-GCM-SHA256:TLS-DHE-RSA-WITH-AES-128-CBC-SHA:TLS_AES_256_GCM_SHA384:TLS-RSA-WITH-AES-256-CBC-SHA", //nolint:lll
|
|
|
|
|
"auth-user-pass " + constants.OpenVPNAuthConf,
|
2022-01-06 06:40:23 -05:00
|
|
|
"auth " + auth,
|
2021-10-05 10:44:15 -07:00
|
|
|
|
|
|
|
|
// Added constant values
|
|
|
|
|
"auth-nocache",
|
|
|
|
|
"mute-replay-warnings",
|
|
|
|
|
"pull-filter ignore \"auth-token\"", // prevent auth failed loops
|
|
|
|
|
"auth-retry nointeract",
|
|
|
|
|
"suppress-timestamps",
|
|
|
|
|
|
|
|
|
|
// Modified variables
|
|
|
|
|
connection.OpenVPNProtoLine(),
|
|
|
|
|
connection.OpenVPNRemoteLine(),
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-05 20:36:23 +00:00
|
|
|
lines = append(lines, utils.CipherLines(settings.Ciphers, settings.Version)...)
|
2021-10-05 10:44:15 -07:00
|
|
|
|
|
|
|
|
if connection.Protocol == constants.UDP {
|
|
|
|
|
lines = append(lines, "explicit-exit-notify")
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-27 23:34:19 +00:00
|
|
|
if settings.ProcessUser != "root" {
|
|
|
|
|
lines = append(lines, "user "+settings.ProcessUser)
|
2021-10-05 10:44:15 -07:00
|
|
|
lines = append(lines, "persist-tun")
|
|
|
|
|
lines = append(lines, "persist-key")
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-06 06:40:23 -05:00
|
|
|
if !*settings.IPv6 {
|
2021-10-05 10:44:15 -07:00
|
|
|
lines = append(lines, `pull-filter ignore "route-ipv6"`)
|
|
|
|
|
lines = append(lines, `pull-filter ignore "ifconfig-ipv6"`)
|
|
|
|
|
// Perfect Privacy specific IPv6
|
|
|
|
|
lines = append(lines, "redirect-gateway def1")
|
|
|
|
|
lines = append(lines, `pull-filter ignore "redirect-gateway def1 ipv6"`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lines = append(lines, utils.WrapOpenvpnCA(
|
|
|
|
|
constants.PerfectprivacyCA)...)
|
|
|
|
|
lines = append(lines, utils.WrapOpenvpnCert(
|
|
|
|
|
constants.PerfectprivacyCert)...)
|
|
|
|
|
lines = append(lines, utils.WrapOpenvpnKey(
|
2022-02-13 01:21:25 +00:00
|
|
|
constants.PerfectprivacyKey)...)
|
2021-10-05 10:44:15 -07:00
|
|
|
lines = append(lines, utils.WrapOpenvpnTLSCrypt(
|
2022-02-13 01:21:25 +00:00
|
|
|
constants.PerfectprivacyTLSCrypt)...)
|
2021-10-05 10:44:15 -07:00
|
|
|
|
|
|
|
|
lines = append(lines, "")
|
|
|
|
|
|
|
|
|
|
return lines, nil
|
|
|
|
|
}
|