From b5eb840d22361d18663182ea40db63431595b6b8 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Tue, 19 Mar 2019 14:14:58 +0300 Subject: [PATCH] + control: use the list of IP addresses instead of single string in "dns_address" "dns_address":"0.0.0.0" -> "dns_addresses":["127.0.0.1", "::1", ...] --- control.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/control.go b/control.go index 0bd7a5d7..e4454fb9 100644 --- a/control.go +++ b/control.go @@ -79,8 +79,25 @@ func httpUpdateConfigReloadDNSReturnOK(w http.ResponseWriter, r *http.Request) { func handleStatus(w http.ResponseWriter, r *http.Request) { log.Tracef("%s %v", r.Method, r.URL) + + dnsAddresses := []string{} + if config.DNS.BindHost == "0.0.0.0" { + ifaces, e := getValidNetInterfacesForWeb() + if e != nil { + log.Error("Couldn't get network interfaces: %v", e) + } + for _, iface := range ifaces { + for _, addr := range iface.Addresses { + dnsAddresses = append(dnsAddresses, addr) + } + } + } + if len(dnsAddresses) == 0 { + dnsAddresses = append(dnsAddresses, config.DNS.BindHost) + } + data := map[string]interface{}{ - "dns_address": config.DNS.BindHost, + "dns_addresses": dnsAddresses, "http_port": config.BindPort, "dns_port": config.DNS.Port, "protection_enabled": config.DNS.ProtectionEnabled,