feat(vpn): auto detection of IPv6 support

- `OPENVPN_IPV6` removed
- Affects OpenVPN
- Use the same mechanism for OpenVPN and Wireguard
- Check only once at program start since this is unlikely to change at runtime
- Log if IPv6 is supported
- Remove `IPv6` boolean from settings structs
- Move IPv6 detection as a method on NetLinker
This commit is contained in:
Quentin McGaw
2022-09-06 12:16:29 +00:00
parent 71c51a7455
commit 5ddd703f6a
45 changed files with 171 additions and 137 deletions

View File

@@ -30,6 +30,9 @@ type Settings struct {
// RulePriority is the priority for the rule created with the
// FirewallMark.
RulePriority int
// IPv6 can bet set to true if IPv6 should be handled.
// It defaults to false if left unset.
IPv6 *bool
}
func (s *Settings) SetDefaults() {
@@ -47,6 +50,11 @@ func (s *Settings) SetDefaults() {
const defaultFirewallMark = 51820
s.FirewallMark = defaultFirewallMark
}
if s.IPv6 == nil {
ipv6 := false // this should be injected from host
s.IPv6 = &ipv6
}
}
var (
@@ -187,6 +195,12 @@ func (s Settings) ToLines(settings ToLinesSettings) (lines []string) {
}
lines = append(lines, fieldPrefix+"Endpoint: "+endpointStr)
ipv6Status := "disabled"
if *s.IPv6 {
ipv6Status = "enabled"
}
lines = append(lines, fieldPrefix+"IPv6: "+ipv6Status)
if s.FirewallMark != 0 {
lines = append(lines, fieldPrefix+"Firewall mark: "+fmt.Sprint(s.FirewallMark))
}