fix bugs
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user