Skip to content

fix: preserve policy group strategies in proxy chains and speed tests - #10436

Open
xysele wants to merge 1 commit into
2dust:masterfrom
xysele:fix/policy-group-strategy-preservation
Open

xysele wants to merge 1 commit into
2dust:masterfrom
xysele:fix/policy-group-strategy-preservation

Conversation

@xysele

@xysele xysele commented Oct 21, 2026

Copy link
Copy Markdown

中文说明

当策略组所属订阅设置了前置或后置代理时,配置生成器会将该策略组包装为虚拟 ProxyChain。原实现没有保留策略组的 MultipleLoad,导致生成的 Xray balancer 回退为 leastPing。例如,订阅设置后置代理后,即使选择“负载均衡”(RoundRobin),生成配置仍使用 leastPing。

批量测速配置也存在相同的策略回退问题:它从批次占位节点读取策略,而非当前被测策略组。

改动

  • 构建订阅代理链时,保留被包装节点的 MultipleLoad。
  • 生成批量测速的 balancer 和探测配置时,使用当前解析后的被测项所选策略。
  • 增加回归测试,覆盖全部五种策略及仅前置、仅后置、同时前置和后置的订阅代理链组合,包括故障转移策略的参数;同时覆盖包含不同策略组的批量测速。

未指定策略时仍默认使用 LeastPing。不涉及数据库迁移或配置格式变更。

验证

  • 新增测试在修复前复现了五项失败。
  • dotnet test --project v2rayN/ServiceLib.Tests -c Release --no-restore:142 项测试通过。
  • dotnet build v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj -c Release --no-restore:在 macOS arm64 上构建通过,0 警告、0 错误。
  • 使用受影响配置数据的副本生成配置,策略由 leastPing 改为 roundRobin;修复前后的 outbound 数量均为 16。
  • Xray 26.3.27 通过 run -test 校验修复后的配置,输出 Configuration OK.。
  • git diff --check 通过。

已在 macOS 确认本次报告的配置问题。两处修复均位于共享的 ServiceLib 代码中;Windows 尚未实机验证。

English

When a policy group belongs to a subscription with a previous or next proxy, it is wrapped in a virtual ProxyChain. That wrapper currently drops the group's MultipleLoad, so the generated Xray balancer falls back to leastPing. For example, selecting load balancing (RoundRobin) still produces leastPing when a subscription post proxy is configured.

Batch speed-test configuration has the same fallback problem: it reads the strategy from the batch's dummy node rather than the current group.

Changes

  • Preserve the wrapped node's MultipleLoad when building a subscription proxy chain.
  • Use the current resolved item's strategy when generating batch speed-test balancers and observatories.
  • Add regression coverage for all five strategies with previous-only, next-only, and combined subscription chains, including fallback settings; also test a batch containing groups with different strategies.

The existing LeastPing default remains in place when no strategy is specified. There are no database migrations or configuration schema changes.

Validation

  • The new tests reproduced five failures before the fix.
  • dotnet test --project v2rayN/ServiceLib.Tests -c Release --no-restore: 142 tests passed.
  • dotnet build v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj -c Release --no-restore: passed on macOS arm64 with 0 warnings and 0 errors.
  • Generating configuration from a copy of the affected profile data changed the strategy from leastPing to roundRobin; both configurations contained 16 outbounds.
  • Xray 26.3.27 accepted the fixed configuration with run -test: Configuration OK.
  • git diff --check: passed.

The reported configuration issue was confirmed on macOS. Both fixes are in shared ServiceLib code; Windows has not been verified on a physical installation.

Fixes #10435

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Xray 策略组配置订阅后置代理后,所选策略仍生成为 leastPing

1 participant