[change] control: fix issues from review

This commit is contained in:
Aleksey Dmitrevskiy 2019-03-07 16:32:52 +03:00
parent 2bd9923691
commit 392c16cd27
1 changed files with 6 additions and 2 deletions

View File

@ -27,6 +27,8 @@ const updatePeriod = time.Minute * 30
var versionCheckJSON []byte var versionCheckJSON []byte
var versionCheckLastTime time.Time var versionCheckLastTime time.Time
var protocols = []string{"tls://", "https://", "tcp://", "sdns://"}
const versionCheckURL = "https://adguardteam.github.io/AdGuardHome/version.json" const versionCheckURL = "https://adguardteam.github.io/AdGuardHome/version.json"
const versionCheckPeriod = time.Hour * 8 const versionCheckPeriod = time.Hour * 8
@ -342,8 +344,10 @@ func handleSetUpstreamConfig(w http.ResponseWriter, r *http.Request) {
} }
func validateUpstream(upstream string) error { func validateUpstream(upstream string) error {
if strings.HasPrefix(upstream, "tls://") || strings.HasPrefix(upstream, "https://") || strings.HasPrefix(upstream, "sdns://") || strings.HasPrefix(upstream, "tcp://") { for _, proto := range protocols {
return nil if strings.HasPrefix(upstream, proto) {
return nil
}
} }
if strings.Contains(upstream, "://") { if strings.Contains(upstream, "://") {