User custom loopback address (#589)

We will probe a set of addresses and port
to define the one available for our DNS service

if none is available, we return an error
This commit is contained in:
Maycon Santos
2022-11-29 11:49:18 +01:00
committed by GitHub
parent 20a73e3e14
commit ae500b63a7
3 changed files with 47 additions and 24 deletions
+3 -3
View File
@@ -257,7 +257,7 @@ func TestDNSServerStartStop(t *testing.T) {
d := net.Dialer{
Timeout: time.Second * 5,
}
addr := fmt.Sprintf("127.0.0.1:%d", port)
addr := fmt.Sprintf("%s:%d", dnsServer.runtimeIP, dnsServer.runtimePort)
conn, err := d.DialContext(ctx, network, addr)
if err != nil {
t.Log(err)
@@ -297,7 +297,7 @@ func getDefaultServerWithNoHostManager(ip string) *DefaultServer {
}
dnsServer := &dns.Server{
Addr: fmt.Sprintf("%s:%d", ip, port),
Addr: fmt.Sprintf("%s:%d", ip, defaultPort),
Net: "udp",
Handler: mux,
UDPSize: 65535,
@@ -314,7 +314,7 @@ func getDefaultServerWithNoHostManager(ip string) *DefaultServer {
localResolver: &localResolver{
registeredMap: make(registrationMap),
},
runtimePort: port,
runtimePort: defaultPort,
runtimeIP: listenIP,
}
}