feat: 新增负载均衡路由 Action 支持 (balancer/balancer_ip/default_balancer)#21
Open
missish wants to merge 9 commits intowyx2685:mainfrom
Open
feat: 新增负载均衡路由 Action 支持 (balancer/balancer_ip/default_balancer)#21missish wants to merge 9 commits intowyx2685:mainfrom
missish wants to merge 9 commits intowyx2685:mainfrom
Conversation
新增三种负载均衡 Action: - balancer: 基于域名匹配的负载均衡 - balancer_ip: 基于 IP 匹配的负载均衡 - default_balancer: 默认出站负载均衡(匹配所有流量) 支持的负载均衡策略: - random: 随机选择(默认) - roundrobin: 轮询 - leastping: 最低延迟(需要 Observatory) - leastload: 最低负载(需要 Observatory)
Owner
|
有一个问题,v2board上action只能写最大11字符,balancer的种类名长度要缩一下 另外需要配套v2board的PR |
Author
抱歉我用的Xboard自行开发的route插件无法提供v2board的PR |
Owner
|
那挂在这 有需要的人自用 |
Author
好吧 |
This reverts commit 39c547d.
- 新增 getActionPriority 函数定义 action 优先级 - 新增 sortRoutesByPriority 函数按优先级排序路由规则 - 优先级顺序: dns → block/protocol → block_ip/block_port → balancer/route → balancer_ip/route_ip → default_out/default_balancer - 使用稳定排序保持同级规则的原始配置顺序
- ProbeInterval 单位是纳秒,之前设置 30 实际是 30 纳秒 - 修改为 10 * time.Second (10秒)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
功能概述
为 v2node 新增三种负载均衡路由 Action,支持将流量分发到多个出站节点,实现高可用和负载均衡。
新增 Action
balancerbalancer_ipdefault_balancer支持的负载均衡策略
randomroundrobinleastpingleastload配置格式
action_value 结构:
{ "tag": "proxy-lb", "outbounds": [ {"tag": "proxy-hk-1", "protocol": "vmess", "settings": {...}, "streamSettings": {...}}, {"tag": "proxy-hk-2", "protocol": "trojan", "settings": {...}, "streamSettings": {...}} ], "strategy": "leastping", "fallbackTag": "direct" }字段说明:
tagoutboundsstrategyrandomfallbackTagAPI 下发示例
balancer(域名匹配):
{ "action": "balancer", "match": ["geosite:netflix", "domain:openai.com"], "action_value": "{\"tag\":\"streaming-lb\",\"outbounds\":[...],\"strategy\":\"leastping\"}" }balancer_ip(IP 匹配):
{ "action": "balancer_ip", "match": ["geoip:us", "1.1.1.1/32"], "action_value": "{\"tag\":\"us-lb\",\"outbounds\":[...],\"strategy\":\"roundrobin\"}" }default_balancer(默认出站):
{ "action": "default_balancer", "match": [], "action_value": "{\"tag\":\"default-lb\",\"outbounds\":[...],\"strategy\":\"random\"}" }变更文件
core/balancer.gocore/custom.gocore/core.gocore/distro/all/all.go技术实现
outbounds数组解析并构建 xray-core OutboundHandlerConfighttps://www.gstatic.com/generate_204注意事项
default_out和default_balancer不应同时配置,会产生冲突(先配置的生效)