mirror of
https://github.com/gravitl/netmaker.git
synced 2025-11-09 08:10:34 +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)
|
// SetDNSWithRetry - Attempt setting dns, if it fails return true (to reset dns)
|
||||||
func SetDNSWithRetry(node models.Node, address string) bool {
|
func SetDNSWithRetry(node models.Node, address string) bool {
|
||||||
var reachable bool
|
var reachable bool
|
||||||
|
if !hasPrereqs() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
for counter := 0; !reachable && counter < 5; counter++ {
|
for counter := 0; !reachable && counter < 5; counter++ {
|
||||||
reachable = IsDNSReachable(address)
|
reachable = IsDNSReachable(address)
|
||||||
time.Sleep(time.Second << 1)
|
time.Sleep(time.Second << 1)
|
||||||
|
|
@ -62,6 +65,14 @@ func SetDNS(nameserver string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hasPrereqs() bool {
|
||||||
|
if !ncutils.IsLinux() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
_, err := exec.LookPath("resolvectl")
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
// UpdateDNS - updates local DNS of client
|
// UpdateDNS - updates local DNS of client
|
||||||
func UpdateDNS(ifacename string, network string, nameserver string) error {
|
func UpdateDNS(ifacename string, network string, nameserver string) error {
|
||||||
if !ncutils.IsLinux() {
|
if !ncutils.IsLinux() {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue