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