From 0010082f2737b6a4f01c53a6b2b12ff66cae72de Mon Sep 17 00:00:00 2001 From: Jan Saidl Date: Sun, 6 Aug 2023 13:03:13 +0200 Subject: [PATCH] z0 - fix VPN DNS setup --- src/vpn/dnsCleanNetworkSetup.go | 17 +++++++++++------ src/vpn/setDnsNetworksetup.go | 25 +++++++++++++++++++++---- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/vpn/dnsCleanNetworkSetup.go b/src/vpn/dnsCleanNetworkSetup.go index c66c553e..2bdd3d57 100644 --- a/src/vpn/dnsCleanNetworkSetup.go +++ b/src/vpn/dnsCleanNetworkSetup.go @@ -2,19 +2,24 @@ package vpn import ( "context" - "fmt" "os" ) func (h *Handler) dnsCleanNetworkSetup(ctx context.Context) error { os.Remove("/etc/resolver/zerops") + { + stdin := "remove State:/Network/Service/zerops_vpn_service/IPv6\n" + if _, err := h.runCommand(ctx, makeCommand("scutil", commandWithStdin(stdin))); err != nil { + return err + } + } - stdin := fmt.Sprintf(`remove State:/Network/Service/zerops_vpn_service/IPv6 -remove Setup:/Network/Service/zerops_vpn_service/IPv6`) - - if _, err := h.runCommand(ctx, makeCommand("scutil", commandWithStdin(stdin))); err != nil { - return err + { + stdin := "remove Setup:/Network/Service/zerops_vpn_service/IPv6\n" + if _, err := h.runCommand(ctx, makeCommand("scutil", commandWithStdin(stdin))); err != nil { + return err + } } return nil diff --git a/src/vpn/setDnsNetworksetup.go b/src/vpn/setDnsNetworksetup.go index beac8c33..1eca0230 100644 --- a/src/vpn/setDnsNetworksetup.go +++ b/src/vpn/setDnsNetworksetup.go @@ -23,18 +23,35 @@ func (h *Handler) setDnsNetworksetup(ctx context.Context) error { return err } - stdin := fmt.Sprintf(`d.init + { + stdin := fmt.Sprintf(`d.init d.add Addresses * fe80::1d04:6b6d:7ad7:85e4 2600:3c03::de:d002 d.add DestAddresses * ::ffff:ffff:ffff:ffff:0:0 :: d.add Flags * 0 0 d.add InterfaceName %s d.add PrefixLength * 64 116 set State:/Network/Service/zerops_vpn_service/IPv6 -set Setup:/Network/Service/zerops_vpn_service/IPv6`, data.InterfaceName) +`, data.InterfaceName) + + if _, err := h.runCommand(ctx, makeCommand("scutil", commandWithStdin(stdin))); err != nil { + return err + } - if _, err := h.runCommand(ctx, makeCommand("scutil", commandWithStdin(stdin))); err != nil { - return err } + { + stdin := fmt.Sprintf(`d.init +d.add Addresses * fe80::1d04:6b6d:7ad7:85e4 2600:3c03::de:d002 +d.add DestAddresses * ::ffff:ffff:ffff:ffff:0:0 :: +d.add Flags * 0 0 +d.add InterfaceName %s +d.add PrefixLength * 64 116 +set Setup:/Network/Service/zerops_vpn_service/IPv6 +`, data.InterfaceName) + if _, err := h.runCommand(ctx, makeCommand("scutil", commandWithStdin(stdin))); err != nil { + return err + } + + } return nil }