* control, client: fix issues from review

This commit is contained in:
Aleksey Dmitrevskiy 2019-03-20 15:19:34 +03:00
parent 9ea5c1abe1
commit a01ba5dd4d
2 changed files with 6 additions and 7 deletions

View File

@ -22,7 +22,7 @@ const Examples = props => (
<code>sdns://...</code> - <span dangerouslySetInnerHTML={{ __html: props.t('example_upstream_sdns') }} />
</li>
<li>
<code>[/host.com/]1.1.1.1</code> - <span dangerouslySetInnerHTML={{ __html: props.t('example_upstream_reserved') }} />
<code>[/example.local/]1.1.1.1</code> - <span dangerouslySetInnerHTML={{ __html: props.t('example_upstream_reserved') }} />
</li>
</ol>
</div>

View File

@ -369,23 +369,22 @@ func validateUpstreams(upstreams []string) error {
return nil
}
func validateUpstream(u string) (defaultUpstream bool, err error) {
func validateUpstream(u string) (bool, error) {
// Check if user tries to specify upstream for domain
defaultUpstream = true
u, defaultUpstream, err = separateUpstream(u)
u, defaultUpstream, err := separateUpstream(u)
if err != nil {
return
return defaultUpstream, err
}
// The special server address '#' means "use the default servers"
if u == "#" && !defaultUpstream {
return
return defaultUpstream, nil
}
// Check if the upstream has a valid protocol prefix
for _, proto := range protocols {
if strings.HasPrefix(u, proto) {
return
return defaultUpstream, nil
}
}