From fa3af372ab7276ca32f241b3c79d326492126d20 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Fri, 14 Jul 2023 15:59:21 +0000 Subject: [PATCH] Use ControlD anycast IP if no system DNS found --- resolver.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/resolver.go b/resolver.go index f61c9bc..2512434 100644 --- a/resolver.go +++ b/resolver.go @@ -29,6 +29,13 @@ const ( var bootstrapDNS = "76.76.2.0" var or = &osResolver{nameservers: nameservers()} +func init() { + if len(or.nameservers) == 0 { + // Add bootstrap DNS in case we did not find any. + or.nameservers = []string{net.JoinHostPort(bootstrapDNS, "53")} + } +} + // Resolver is the interface that wraps the basic DNS operations. // // Resolve resolves the DNS query, return the result and the corresponding error.