[fix] control: fix json decode for upstream config
This commit is contained in:
parent
5d6c980ac7
commit
ceaa1e4ebf
14
control.go
14
control.go
|
@ -308,9 +308,9 @@ func sortByValue(m map[string]int) []string {
|
||||||
|
|
||||||
// TODO this struct will become unnecessary after config file rework
|
// TODO this struct will become unnecessary after config file rework
|
||||||
type upstreamConfig struct {
|
type upstreamConfig struct {
|
||||||
upstreams []string // Upstreams
|
Upstreams []string `json:"upstream_dns"` // Upstreams
|
||||||
bootstrapDNS []string // Bootstrap DNS
|
BootstrapDNS []string `json:"bootstrap_dns"` // Bootstrap DNS
|
||||||
allServers bool // --all-servers param for dnsproxy
|
AllServers bool `json:"all_servers"` // --all-servers param for dnsproxy
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleSetUpstreamConfig(w http.ResponseWriter, r *http.Request) {
|
func handleSetUpstreamConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -323,13 +323,13 @@ func handleSetUpstreamConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
config.DNS.UpstreamDNS = defaultDNS
|
config.DNS.UpstreamDNS = defaultDNS
|
||||||
if len(newconfig.upstreams) > 0 {
|
if len(newconfig.Upstreams) > 0 {
|
||||||
config.DNS.UpstreamDNS = newconfig.upstreams
|
config.DNS.UpstreamDNS = newconfig.Upstreams
|
||||||
}
|
}
|
||||||
|
|
||||||
// bootstrap servers are plain DNS only. We should remove tls:// https:// and sdns:// hosts from slice
|
// bootstrap servers are plain DNS only. We should remove tls:// https:// and sdns:// hosts from slice
|
||||||
bootstraps := []string{}
|
bootstraps := []string{}
|
||||||
for _, host := range newconfig.bootstrapDNS {
|
for _, host := range newconfig.BootstrapDNS {
|
||||||
err := checkBootstrapDNS(host)
|
err := checkBootstrapDNS(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Tracef("%s can not be used as bootstrap DNS cause: %s", host, err)
|
log.Tracef("%s can not be used as bootstrap DNS cause: %s", host, err)
|
||||||
|
@ -343,7 +343,7 @@ func handleSetUpstreamConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
config.DNS.BootstrapDNS = bootstraps
|
config.DNS.BootstrapDNS = bootstraps
|
||||||
}
|
}
|
||||||
|
|
||||||
config.DNS.AllServers = newconfig.allServers
|
config.DNS.AllServers = newconfig.AllServers
|
||||||
httpUpdateConfigReloadDNSReturnOK(w, r)
|
httpUpdateConfigReloadDNSReturnOK(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue