From ceaa1e4ebf2e29c972b8ed0f4d7cf54e13f85151 Mon Sep 17 00:00:00 2001 From: Aleksey Dmitrevskiy Date: Wed, 6 Mar 2019 15:35:22 +0300 Subject: [PATCH] [fix] control: fix json decode for upstream config --- control.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/control.go b/control.go index 0bc6fc66..6f36c3ca 100644 --- a/control.go +++ b/control.go @@ -308,9 +308,9 @@ func sortByValue(m map[string]int) []string { // TODO this struct will become unnecessary after config file rework type upstreamConfig struct { - upstreams []string // Upstreams - bootstrapDNS []string // Bootstrap DNS - allServers bool // --all-servers param for dnsproxy + Upstreams []string `json:"upstream_dns"` // Upstreams + BootstrapDNS []string `json:"bootstrap_dns"` // Bootstrap DNS + AllServers bool `json:"all_servers"` // --all-servers param for dnsproxy } func handleSetUpstreamConfig(w http.ResponseWriter, r *http.Request) { @@ -323,13 +323,13 @@ func handleSetUpstreamConfig(w http.ResponseWriter, r *http.Request) { } config.DNS.UpstreamDNS = defaultDNS - if len(newconfig.upstreams) > 0 { - config.DNS.UpstreamDNS = newconfig.upstreams + if len(newconfig.Upstreams) > 0 { + config.DNS.UpstreamDNS = newconfig.Upstreams } // bootstrap servers are plain DNS only. We should remove tls:// https:// and sdns:// hosts from slice bootstraps := []string{} - for _, host := range newconfig.bootstrapDNS { + for _, host := range newconfig.BootstrapDNS { err := checkBootstrapDNS(host) if err != nil { 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.AllServers = newconfig.allServers + config.DNS.AllServers = newconfig.AllServers httpUpdateConfigReloadDNSReturnOK(w, r) }