* /status: "dns_addresses": add port if not 53
This commit is contained in:
parent
1445940473
commit
ad7c5cb9dc
@ -80,27 +80,43 @@ func httpUpdateConfigReloadDNSReturnOK(w http.ResponseWriter, r *http.Request) {
|
|||||||
returnOK(w)
|
returnOK(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleStatus(w http.ResponseWriter, r *http.Request) {
|
func addDNSAddress(dnsAddresses *[]string, addr string) {
|
||||||
log.Tracef("%s %v", r.Method, r.URL)
|
if config.DNS.Port != 53 {
|
||||||
|
addr = fmt.Sprintf("%s:%d", addr, config.DNS.Port)
|
||||||
|
}
|
||||||
|
*dnsAddresses = append(*dnsAddresses, addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the list of DNS addresses the server is listening on
|
||||||
|
func getDNSAddresses() []string {
|
||||||
dnsAddresses := []string{}
|
dnsAddresses := []string{}
|
||||||
|
|
||||||
if config.DNS.BindHost == "0.0.0.0" {
|
if config.DNS.BindHost == "0.0.0.0" {
|
||||||
|
|
||||||
ifaces, e := getValidNetInterfacesForWeb()
|
ifaces, e := getValidNetInterfacesForWeb()
|
||||||
if e != nil {
|
if e != nil {
|
||||||
log.Error("Couldn't get network interfaces: %v", e)
|
log.Error("Couldn't get network interfaces: %v", e)
|
||||||
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, iface := range ifaces {
|
for _, iface := range ifaces {
|
||||||
for _, addr := range iface.Addresses {
|
for _, addr := range iface.Addresses {
|
||||||
dnsAddresses = append(dnsAddresses, addr)
|
addDNSAddress(&dnsAddresses, addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if len(dnsAddresses) == 0 {
|
} else {
|
||||||
dnsAddresses = append(dnsAddresses, config.DNS.BindHost)
|
addDNSAddress(&dnsAddresses, config.DNS.BindHost)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return dnsAddresses
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log.Tracef("%s %v", r.Method, r.URL)
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"dns_addresses": dnsAddresses,
|
"dns_addresses": getDNSAddresses(),
|
||||||
"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,
|
||||||
|
Loading…
Reference in New Issue
Block a user