fix bugs
This commit is contained in:
parent
544aacf0fd
commit
b0b783f7c8
@ -2,6 +2,6 @@ proxy:{% for i in instances %}
|
|||||||
- url: "socks5://192.168.122.128:{{1080+i["idx"]}}"
|
- url: "socks5://192.168.122.128:{{1080+i["idx"]}}"
|
||||||
weight: {{i["weight"]}}
|
weight: {{i["weight"]}}
|
||||||
{% end %}
|
{% end %}
|
||||||
load-balance-mode: "cached-shuffle"
|
load-balance-mode: "{{load_balance_mode}}"
|
||||||
cache-max-length: 256
|
cache-max-length: 256
|
||||||
dynamic-weight-file: "{{dynamic_weight_fp}}"
|
dynamic-weight-file: "{{dynamic_weight_fp}}"
|
||||||
|
|||||||
@ -152,6 +152,8 @@ func (pm *ProxyManager) DescribeLoadBalanceMode() string {
|
|||||||
return fmt.Sprintf("sticky with maximum cache size of %d", pm.CacheMaxLength)
|
return fmt.Sprintf("sticky with maximum cache size of %d", pm.CacheMaxLength)
|
||||||
} else if pm.LoadBalanceMode == cachedShuffle {
|
} else if pm.LoadBalanceMode == cachedShuffle {
|
||||||
return fmt.Sprintf("cached shuffle with maximum cache size of %d", pm.CacheMaxLength)
|
return fmt.Sprintf("cached shuffle with maximum cache size of %d", pm.CacheMaxLength)
|
||||||
|
} else if pm.LoadBalanceMode == fallback {
|
||||||
|
return "fallback mode"
|
||||||
} else {
|
} else {
|
||||||
return "randomize every connection"
|
return "randomize every connection"
|
||||||
}
|
}
|
||||||
@ -214,12 +216,10 @@ func (pm *ProxyManager) Get(addr string) (string, bool) {
|
|||||||
} else if pm.LoadBalanceMode == fallback {
|
} else if pm.LoadBalanceMode == fallback {
|
||||||
addr := "*"
|
addr := "*"
|
||||||
idx, ok := pm.Cache.Get(addr)
|
idx, ok := pm.Cache.Get(addr)
|
||||||
if ok {
|
if !ok {
|
||||||
idx = (idx + 1) % (len(pm.enabledIndics))
|
|
||||||
} else {
|
|
||||||
idx = pm.Chooser.Pick().(int)
|
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
|
return pm.Proxys[pm.enabledIndics[idx]].URL, true
|
||||||
} else {
|
} else {
|
||||||
idx := pm.Chooser.Pick().(int)
|
idx := pm.Chooser.Pick().(int)
|
||||||
|
|||||||
@ -41,10 +41,10 @@ class OManager:
|
|||||||
|
|
||||||
def generate_lb_cfg(self, load_balance_mode):
|
def generate_lb_cfg(self, load_balance_mode):
|
||||||
lb_cfg_fp = os.path.join(
|
lb_cfg_fp = os.path.join(
|
||||||
self.base_folder, "go-socks-lb.yml")
|
self.base_folder, f"go-socks-lb-{load_balance_mode}.yml")
|
||||||
|
|
||||||
self.dynamic_weight_fp = os.path.join(self.base_folder, "weights.json")
|
self.dynamic_weight_fp = os.path.join(self.base_folder, "weights.json")
|
||||||
with open(f"go-socks-lb-{load_balance_mode}.yml.template", "r") as template_f:
|
with open(f"go-socks-lb.yml.template", "r") as template_f:
|
||||||
buf = template_f.read()
|
buf = template_f.read()
|
||||||
template = Template(buf)
|
template = Template(buf)
|
||||||
items = {
|
items = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user