mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-05-15 00:50:25 +02:00
all: always reset DNS before initializing OS resolver
So ctrld could always get the correct nameservers used by system to be used for its OS resolver.
This commit is contained in:
committed by
Cuong Manh Le
parent
411f7434f4
commit
5aca118dbb
+11
-5
@@ -32,12 +32,8 @@ const (
|
||||
|
||||
const bootstrapDNS = "76.76.2.22"
|
||||
|
||||
// OsNameservers is the list of DNS nameservers used by OS resolver.
|
||||
// This reads OS settings at the time ctrld process starts.
|
||||
var OsNameservers = defaultNameservers()
|
||||
|
||||
// or is the Resolver used for ResolverTypeOS.
|
||||
var or = &osResolver{nameservers: OsNameservers}
|
||||
var or = &osResolver{nameservers: defaultNameservers()}
|
||||
|
||||
// defaultNameservers returns nameservers used by the OS.
|
||||
// If no nameservers can be found, ctrld bootstrap nameserver will be used.
|
||||
@@ -49,6 +45,16 @@ func defaultNameservers() []string {
|
||||
return ns
|
||||
}
|
||||
|
||||
// InitializeOsResolver initializes OS resolver using the current system DNS settings.
|
||||
// It returns the nameservers that is going to be used by the OS resolver.
|
||||
//
|
||||
// It's the caller's responsibility to ensure the system DNS is in a clean state before
|
||||
// calling this function.
|
||||
func InitializeOsResolver() []string {
|
||||
or.nameservers = defaultNameservers()
|
||||
return or.nameservers
|
||||
}
|
||||
|
||||
// Resolver is the interface that wraps the basic DNS operations.
|
||||
//
|
||||
// Resolve resolves the DNS query, return the result and the corresponding error.
|
||||
|
||||
Reference in New Issue
Block a user