Fix: when both providers and proxies are present, use the health check configuration for proxies (#1821)
Co-authored-by: Ho <ho@fluidex.com>
This commit is contained in:
parent
4d8017574c
commit
e1fe9c6157
1 changed files with 16 additions and 27 deletions
|
@ -59,8 +59,12 @@ func ParseProxyGroup(config map[string]interface{}, proxyMap map[string]C.Proxy,
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// if Use not empty, drop health check options
|
if _, ok := providersMap[groupName]; ok {
|
||||||
if len(groupOption.Use) != 0 {
|
return nil, errDuplicateProvider
|
||||||
|
}
|
||||||
|
|
||||||
|
// select don't need health check
|
||||||
|
if groupOption.Type == "select" || groupOption.Type == "relay" {
|
||||||
hc := provider.NewHealthCheck(ps, "", 0, true)
|
hc := provider.NewHealthCheck(ps, "", 0, true)
|
||||||
pd, err := provider.NewCompatibleProvider(groupName, ps, hc)
|
pd, err := provider.NewCompatibleProvider(groupName, ps, hc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -68,35 +72,20 @@ func ParseProxyGroup(config map[string]interface{}, proxyMap map[string]C.Proxy,
|
||||||
}
|
}
|
||||||
|
|
||||||
providers = append(providers, pd)
|
providers = append(providers, pd)
|
||||||
|
providersMap[groupName] = pd
|
||||||
} else {
|
} else {
|
||||||
if _, ok := providersMap[groupName]; ok {
|
if groupOption.URL == "" || groupOption.Interval == 0 {
|
||||||
return nil, errDuplicateProvider
|
return nil, errMissHealthCheck
|
||||||
}
|
}
|
||||||
|
|
||||||
// select don't need health check
|
hc := provider.NewHealthCheck(ps, groupOption.URL, uint(groupOption.Interval), groupOption.Lazy)
|
||||||
if groupOption.Type == "select" || groupOption.Type == "relay" {
|
pd, err := provider.NewCompatibleProvider(groupName, ps, hc)
|
||||||
hc := provider.NewHealthCheck(ps, "", 0, true)
|
if err != nil {
|
||||||
pd, err := provider.NewCompatibleProvider(groupName, ps, hc)
|
return nil, err
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
providers = append(providers, pd)
|
|
||||||
providersMap[groupName] = pd
|
|
||||||
} else {
|
|
||||||
if groupOption.URL == "" || groupOption.Interval == 0 {
|
|
||||||
return nil, errMissHealthCheck
|
|
||||||
}
|
|
||||||
|
|
||||||
hc := provider.NewHealthCheck(ps, groupOption.URL, uint(groupOption.Interval), groupOption.Lazy)
|
|
||||||
pd, err := provider.NewCompatibleProvider(groupName, ps, hc)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
providers = append(providers, pd)
|
|
||||||
providersMap[groupName] = pd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
providers = append(providers, pd)
|
||||||
|
providersMap[groupName] = pd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue