From 6056d711a6b42e4296ab64d35b98de96424f5da0 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Fri, 31 Dec 2021 22:45:50 +0000 Subject: [PATCH] fix dns issues on checkin when resolvconf not installed --- netclient/command/commands.go | 4 ++-- netclient/functions/checkin.go | 8 ++++---- netclient/wireguard/common.go | 9 ++++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/netclient/command/commands.go b/netclient/command/commands.go index baa07a3c..3f2090f6 100644 --- a/netclient/command/commands.go +++ b/netclient/command/commands.go @@ -99,8 +99,8 @@ func RunUserspaceDaemon() { } func CheckIn(cfg config.ClientConfig) error { - log.Println("checkin --- diabled for now") - return nil + //log.Println("checkin --- diabled for now") + //return nil var err error var errN error if cfg.Network == "" { diff --git a/netclient/functions/checkin.go b/netclient/functions/checkin.go index 3bd11859..0b6c61b2 100644 --- a/netclient/functions/checkin.go +++ b/netclient/functions/checkin.go @@ -156,7 +156,7 @@ func Pull(network string, manual bool) (*models.Node, error) { } node := cfg.Node - servercfg := cfg.Server + //servercfg := cfg.Server if cfg.Node.IPForwarding == "yes" && !ncutils.IsWindows() { if err = local.SetIPForwarding(); err != nil { @@ -241,9 +241,9 @@ func Pull(network string, manual bool) (*models.Node, error) { } } } - if ncutils.IsLinux() { - setDNS(&resNode, servercfg, &cfg.Node) - } + //if ncutils.IsLinux() { + // setDNS(&resNode, servercfg, &cfg.Node) + //} var bkupErr = config.SaveBackup(network) if bkupErr != nil { ncutils.Log("unable to update backup file") diff --git a/netclient/wireguard/common.go b/netclient/wireguard/common.go index f256de81..6df8dde3 100644 --- a/netclient/wireguard/common.go +++ b/netclient/wireguard/common.go @@ -4,6 +4,7 @@ import ( "errors" "io/ioutil" "log" + "os/exec" "runtime" "strconv" "strings" @@ -135,8 +136,14 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig if node.Address == "" { log.Fatal("no address to configure") } - var nameserver string + if ncutils.IsLinux() { + if _, err := exec.LookPath("resolvconf"); err != nil { + ncutils.PrintLog("resolvconf not present", 2) + ncutils.PrintLog("unable to configure DNS automatically, disabling automated DNS management", 2) + node.DNSOn = "no" + } + } if node.DNSOn == "yes" { nameserver = servercfg.CoreDNSAddr }