Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] balancer enhancement #323

Closed
Xray9 opened this issue Mar 1, 2021 · 5 comments
Closed

[Feature Request] balancer enhancement #323

Xray9 opened this issue Mar 1, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@Xray9
Copy link
Contributor

Xray9 commented Mar 1, 2021

目前的 balancer 的功能有些太过简陋(与文档中的 选出一个最合适的outbound 相去甚远),我觉得我们可以增强它,譬如可以加上一个可用性判断,以及更多

func (s *RandomStrategy) PickOutbound(tags []string) string {
n := len(tags)
if n == 0 {
panic("0 tags")
}
return tags[dice.Roll(n)]
}

// Select implements outbound.HandlerSelector.
func (m *Manager) Select(selectors []string) []string {
m.access.RLock()
defer m.access.RUnlock()
tags := make([]string, 0, len(selectors))
for tag := range m.taggedHandler {
match := false
for _, selector := range selectors {
if strings.HasPrefix(tag, selector) {
match = true
break
}
}
if match {
tags = append(tags, tag)
}
}
return tags
}

@AkinoKaede
Copy link
Contributor

v2fly/v2ray-core#589

@Xray9
Copy link
Contributor Author

Xray9 commented Mar 1, 2021

@AkinoKaede 这个pr很好啊, 决定了基于这个改改提到这边来

@RPRX
Copy link
Member

RPRX commented Mar 1, 2021

@Xray9 其实可以先合再改

@AkinoKaede AkinoKaede added the enhancement New feature or request label Mar 3, 2021
@hronro
Copy link

hronro commented Apr 15, 2021

link related PR #168

@lelemka0
Copy link
Contributor

lelemka0 commented May 2, 2023

有任何进展吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants