Fix: weak type proxy name
This commit is contained in:
parent
e12d46f619
commit
19cbe52456
1 changed files with 9 additions and 8 deletions
|
@ -250,14 +250,10 @@ func (c *Config) parseProxies(cfg *RawConfig) error {
|
||||||
// parse proxy
|
// parse proxy
|
||||||
for idx, mapping := range proxiesConfig {
|
for idx, mapping := range proxiesConfig {
|
||||||
proxyType, existType := mapping["type"].(string)
|
proxyType, existType := mapping["type"].(string)
|
||||||
proxyName, existName := mapping["name"].(string)
|
if !existType {
|
||||||
if !existType && existName {
|
return fmt.Errorf("Proxy %d missing type", idx)
|
||||||
return fmt.Errorf("Proxy %d missing type or name", idx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, exist := proxies[proxyName]; exist {
|
|
||||||
return fmt.Errorf("Proxy %s is the duplicate name", proxyName)
|
|
||||||
}
|
|
||||||
var proxy C.Proxy
|
var proxy C.Proxy
|
||||||
var err error
|
var err error
|
||||||
switch proxyType {
|
switch proxyType {
|
||||||
|
@ -285,10 +281,15 @@ func (c *Config) parseProxies(cfg *RawConfig) error {
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("Unsupport proxy type: %s", proxyType)
|
return fmt.Errorf("Unsupport proxy type: %s", proxyType)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Proxy %s: %s", proxyName, err.Error())
|
return fmt.Errorf("Proxy [%d]: %s", idx, err.Error())
|
||||||
}
|
}
|
||||||
proxies[proxyName] = proxy
|
|
||||||
|
if _, exist := proxies[proxy.Name()]; exist {
|
||||||
|
return fmt.Errorf("Proxy %s is the duplicate name", proxy.Name())
|
||||||
|
}
|
||||||
|
proxies[proxy.Name()] = proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse proxy group
|
// parse proxy group
|
||||||
|
|
Loading…
Reference in a new issue