Maint: OpenVPN: only add persist-key when running without root
This commit is contained in:
@@ -41,6 +41,7 @@ func modifyConfig(lines []string, connection models.Connection,
|
||||
line == "auth-retry nointeract",
|
||||
line == "suppress-timestamps",
|
||||
line == "persist-tun",
|
||||
line == "persist-key",
|
||||
// Remove values always modified
|
||||
strings.HasPrefix(line, "verb "),
|
||||
strings.HasPrefix(line, "auth-user-pass "),
|
||||
@@ -90,6 +91,7 @@ func modifyConfig(lines []string, connection models.Connection,
|
||||
if !settings.Root {
|
||||
modified = append(modified, "user "+settings.ProcUser)
|
||||
modified = append(modified, "persist-tun")
|
||||
modified = append(modified, "persist-key")
|
||||
}
|
||||
|
||||
modified = append(modified, "") // trailing line
|
||||
|
||||
@@ -64,6 +64,7 @@ func Test_modifyConfig(t *testing.T) {
|
||||
"pull-filter ignore \"ifconfig-ipv6\"",
|
||||
"user procuser",
|
||||
"persist-tun",
|
||||
"persist-key",
|
||||
"",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -24,7 +24,6 @@ func (c *Cyberghost) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"remote-cert-tls server",
|
||||
"ping 10",
|
||||
"ping-exit 60",
|
||||
@@ -60,6 +59,7 @@ func (c *Cyberghost) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if settings.MSSFix > 0 {
|
||||
|
||||
@@ -25,7 +25,6 @@ func (f *Fastestvpn) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"ping 15",
|
||||
"ping-exit 60",
|
||||
"tls-exit",
|
||||
@@ -59,6 +58,7 @@ func (f *Fastestvpn) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if !settings.IPv6 {
|
||||
|
||||
@@ -19,7 +19,6 @@ func (h *HideMyAss) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"ping 5",
|
||||
"ping-exit 30",
|
||||
"tls-exit",
|
||||
@@ -55,6 +54,7 @@ func (h *HideMyAss) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if !settings.IPv6 {
|
||||
|
||||
@@ -22,7 +22,6 @@ func (i *Ipvanish) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"tls-exit",
|
||||
|
||||
// Ipvanish specific
|
||||
@@ -53,6 +52,7 @@ func (i *Ipvanish) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if !settings.IPv6 {
|
||||
|
||||
@@ -22,7 +22,6 @@ func (i *Ivpn) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"ping 5",
|
||||
"ping-exit 30",
|
||||
"tls-exit",
|
||||
@@ -60,6 +59,7 @@ func (i *Ivpn) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if !settings.IPv6 {
|
||||
|
||||
@@ -19,7 +19,6 @@ func (m *Mullvad) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"remote-cert-tls server",
|
||||
"ping 10",
|
||||
"ping-exit 60",
|
||||
@@ -62,6 +61,7 @@ func (m *Mullvad) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if settings.MSSFix > 0 {
|
||||
|
||||
@@ -27,7 +27,6 @@ func (n *Nordvpn) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"remote-cert-tls server",
|
||||
"tls-exit",
|
||||
|
||||
@@ -64,6 +63,7 @@ func (n *Nordvpn) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if !settings.IPv6 {
|
||||
|
||||
@@ -23,7 +23,6 @@ func (p *Privado) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"ping 10",
|
||||
"ping-exit 60",
|
||||
"tls-exit",
|
||||
@@ -52,6 +51,7 @@ func (p *Privado) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if settings.MSSFix > 0 {
|
||||
|
||||
@@ -42,7 +42,6 @@ func (p *PIA) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"remote-cert-tls server",
|
||||
|
||||
// PIA specific
|
||||
@@ -74,6 +73,7 @@ func (p *PIA) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if settings.MSSFix > 0 {
|
||||
|
||||
@@ -23,7 +23,6 @@ func (p *Privatevpn) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"remote-cert-tls server",
|
||||
"tls-exit",
|
||||
|
||||
@@ -53,6 +52,7 @@ func (p *Privatevpn) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if settings.MSSFix > 0 {
|
||||
|
||||
@@ -28,7 +28,6 @@ func (p *Protonvpn) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"remote-cert-tls server",
|
||||
"tls-exit",
|
||||
|
||||
@@ -64,6 +63,7 @@ func (p *Protonvpn) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if !settings.IPv6 {
|
||||
|
||||
@@ -19,7 +19,6 @@ func (p *Purevpn) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"remote-cert-tls server",
|
||||
"ping 10",
|
||||
"ping-exit 60",
|
||||
@@ -61,6 +60,7 @@ func (p *Purevpn) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if !settings.IPv6 {
|
||||
|
||||
@@ -28,7 +28,6 @@ func (s *Surfshark) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"remote-cert-tls server",
|
||||
"ping 15",
|
||||
"tls-exit",
|
||||
@@ -61,6 +60,7 @@ func (s *Surfshark) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if !settings.IPv6 {
|
||||
|
||||
@@ -28,7 +28,6 @@ func (t *Torguard) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"remote-cert-tls server",
|
||||
"tls-exit",
|
||||
|
||||
@@ -62,6 +61,7 @@ func (t *Torguard) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if connection.Protocol == constants.UDP {
|
||||
|
||||
@@ -15,7 +15,6 @@ func (p *Provider) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"tls-exit",
|
||||
"remote-cert-tls server",
|
||||
|
||||
@@ -53,6 +52,7 @@ func (p *Provider) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if !settings.IPv6 {
|
||||
|
||||
@@ -23,7 +23,6 @@ func (v *Vyprvpn) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"remote-cert-tls server",
|
||||
"ping 10",
|
||||
"ping-exit 60",
|
||||
@@ -53,6 +52,7 @@ func (v *Vyprvpn) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if settings.MSSFix > 0 {
|
||||
|
||||
@@ -24,7 +24,6 @@ func (w *Windscribe) BuildConf(connection models.Connection,
|
||||
"client",
|
||||
"dev " + settings.Interface,
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"remote-cert-tls server",
|
||||
"ping 10",
|
||||
"ping-exit 60",
|
||||
@@ -59,6 +58,7 @@ func (w *Windscribe) BuildConf(connection models.Connection,
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+settings.ProcUser)
|
||||
lines = append(lines, "persist-tun")
|
||||
lines = append(lines, "persist-key")
|
||||
}
|
||||
|
||||
if settings.MSSFix > 0 {
|
||||
|
||||
Reference in New Issue
Block a user