fix dns issues on checkin when resolvconf not installed

This commit is contained in:
Matthew R Kasun 2021-12-31 22:45:50 +00:00
parent 45464c00f5
commit 6056d711a6
3 changed files with 14 additions and 7 deletions

View file

@ -99,8 +99,8 @@ func RunUserspaceDaemon() {
} }
func CheckIn(cfg config.ClientConfig) error { func CheckIn(cfg config.ClientConfig) error {
log.Println("checkin --- diabled for now") //log.Println("checkin --- diabled for now")
return nil //return nil
var err error var err error
var errN error var errN error
if cfg.Network == "" { if cfg.Network == "" {

View file

@ -156,7 +156,7 @@ func Pull(network string, manual bool) (*models.Node, error) {
} }
node := cfg.Node node := cfg.Node
servercfg := cfg.Server //servercfg := cfg.Server
if cfg.Node.IPForwarding == "yes" && !ncutils.IsWindows() { if cfg.Node.IPForwarding == "yes" && !ncutils.IsWindows() {
if err = local.SetIPForwarding(); err != nil { if err = local.SetIPForwarding(); err != nil {
@ -241,9 +241,9 @@ func Pull(network string, manual bool) (*models.Node, error) {
} }
} }
} }
if ncutils.IsLinux() { //if ncutils.IsLinux() {
setDNS(&resNode, servercfg, &cfg.Node) // setDNS(&resNode, servercfg, &cfg.Node)
} //}
var bkupErr = config.SaveBackup(network) var bkupErr = config.SaveBackup(network)
if bkupErr != nil { if bkupErr != nil {
ncutils.Log("unable to update backup file") ncutils.Log("unable to update backup file")

View file

@ -4,6 +4,7 @@ import (
"errors" "errors"
"io/ioutil" "io/ioutil"
"log" "log"
"os/exec"
"runtime" "runtime"
"strconv" "strconv"
"strings" "strings"
@ -135,8 +136,14 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
if node.Address == "" { if node.Address == "" {
log.Fatal("no address to configure") log.Fatal("no address to configure")
} }
var nameserver string 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" { if node.DNSOn == "yes" {
nameserver = servercfg.CoreDNSAddr nameserver = servercfg.CoreDNSAddr
} }