This commit is contained in:
2020-04-18 00:19:20 -04:00
parent 544aacf0fd
commit b0b783f7c8
3 changed files with 7 additions and 7 deletions
+4 -4
View File
@@ -152,6 +152,8 @@ func (pm *ProxyManager) DescribeLoadBalanceMode() string {
return fmt.Sprintf("sticky with maximum cache size of %d", pm.CacheMaxLength)
} else if pm.LoadBalanceMode == cachedShuffle {
return fmt.Sprintf("cached shuffle with maximum cache size of %d", pm.CacheMaxLength)
} else if pm.LoadBalanceMode == fallback {
return "fallback mode"
} else {
return "randomize every connection"
}
@@ -214,12 +216,10 @@ func (pm *ProxyManager) Get(addr string) (string, bool) {
} else if pm.LoadBalanceMode == fallback {
addr := "*"
idx, ok := pm.Cache.Get(addr)
if ok {
idx = (idx + 1) % (len(pm.enabledIndics))
} else {
if !ok {
idx = pm.Chooser.Pick().(int)
pm.Cache.SetTrim(addr, idx, pm.CacheMaxLength)
}
pm.Cache.SetTrim(addr, idx, pm.CacheMaxLength)
return pm.Proxys[pm.enabledIndics[idx]].URL, true
} else {
idx := pm.Chooser.Pick().(int)