+ 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", ...]
This commit is contained in:
Simon Zolin 2019-03-19 14:14:58 +03:00
parent 6f56eb4c12
commit b5eb840d22
1 changed files with 18 additions and 1 deletions

View File

@ -79,8 +79,25 @@ func httpUpdateConfigReloadDNSReturnOK(w http.ResponseWriter, r *http.Request) {
func handleStatus(w http.ResponseWriter, r *http.Request) { func handleStatus(w http.ResponseWriter, r *http.Request) {
log.Tracef("%s %v", r.Method, r.URL) 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{}{ data := map[string]interface{}{
"dns_address": config.DNS.BindHost, "dns_addresses": dnsAddresses,
"http_port": config.BindPort, "http_port": config.BindPort,
"dns_port": config.DNS.Port, "dns_port": config.DNS.Port,
"protection_enabled": config.DNS.ProtectionEnabled, "protection_enabled": config.DNS.ProtectionEnabled,