mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-17 18:45:01 +08:00
extra check on dns
This commit is contained in:
parent
ea7cb6f39e
commit
fb8def3315
1 changed files with 11 additions and 0 deletions
|
@ -20,6 +20,9 @@ const DNS_UNREACHABLE_ERROR = "nameserver unreachable"
|
|||
// SetDNSWithRetry - Attempt setting dns, if it fails return true (to reset dns)
|
||||
func SetDNSWithRetry(node models.Node, address string) bool {
|
||||
var reachable bool
|
||||
if !hasPrereqs() {
|
||||
return true
|
||||
}
|
||||
for counter := 0; !reachable && counter < 5; counter++ {
|
||||
reachable = IsDNSReachable(address)
|
||||
time.Sleep(time.Second << 1)
|
||||
|
@ -62,6 +65,14 @@ func SetDNS(nameserver string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func hasPrereqs() bool {
|
||||
if !ncutils.IsLinux() {
|
||||
return false
|
||||
}
|
||||
_, err := exec.LookPath("resolvectl")
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// UpdateDNS - updates local DNS of client
|
||||
func UpdateDNS(ifacename string, network string, nameserver string) error {
|
||||
if !ncutils.IsLinux() {
|
||||
|
|
Loading…
Add table
Reference in a new issue