From 14fdd493a387aa0f7bfc1763d9684d1b2a625bcf Mon Sep 17 00:00:00 2001 From: Qiu Yuzhou Date: Sat, 3 Oct 2026 11:21:37 +0800 Subject: [PATCH] fix(rules-smoke): adapt smoke fixtures to sourceless ProxyRule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fcd5645「slim built-in snapshots」移除了 ProxyRule 的 source 字段后 Smoke target 未同步,构造器多传 source: 导致冒烟编译失败(先于收敛脊柱重构就 存在的破损)。移除冒烟夹具中的 source 实参与不再使用的 RuleSourceIdentity 局部值;来源身份属于浏览集合层,运行时文档与 ACL 只消费 action+match, 夹具语义不变。 --- .../Smoke/RealSslocalSmokeTests+ACLRouting.swift | 14 +++----------- .../RealSslocalSmokeTests+CustomRules.swift | 16 ++++------------ .../Smoke/RealSslocalSmokeTests+GFWListACL.swift | 8 ++------ 3 files changed, 9 insertions(+), 29 deletions(-) diff --git a/ShadowsocksX-NG2/Tests/Smoke/RealSslocalSmokeTests+ACLRouting.swift b/ShadowsocksX-NG2/Tests/Smoke/RealSslocalSmokeTests+ACLRouting.swift index f8076925..64f31855 100644 --- a/ShadowsocksX-NG2/Tests/Smoke/RealSslocalSmokeTests+ACLRouting.swift +++ b/ShadowsocksX-NG2/Tests/Smoke/RealSslocalSmokeTests+ACLRouting.swift @@ -99,9 +99,7 @@ extension RealSslocalSmokeTests { socksPort: selectedPorts[0], httpPort: selectedPorts[1]) let chinaRules = [ ProxyRule( - action: .direct, match: try RuleMatch(nationalDomainSuffix: "cn"), - source: RuleSourceIdentity( - kind: .geolocationCN, upstreamVersion: "test", label: "geolocation-cn")) + action: .direct, match: try RuleMatch(nationalDomainSuffix: "cn")) ] let document = SslocalRuntimeDocument( servers: [ @@ -176,17 +174,11 @@ extension RealSslocalSmokeTests { /// issue #64 冒烟夹具:`.cn` 域名 + 测试用 `8.8.8.0/24` CIDR 直连候选 /// (仅验证命中/未命中路由,不代表真实中国 IP 归属)。 private func chinaCIDRSmokeRules() throws -> [ProxyRule] { - let domainSource = RuleSourceIdentity( - kind: .geolocationCN, upstreamVersion: "test", label: "geolocation-cn") - let cidrSource = RuleSourceIdentity( - kind: .chinaIPv4, upstreamVersion: "test", label: "china-operator-ip") return [ ProxyRule( - action: .direct, match: try RuleMatch(nationalDomainSuffix: "cn"), - source: domainSource), + action: .direct, match: try RuleMatch(nationalDomainSuffix: "cn")), ProxyRule( - action: .direct, match: try RuleMatch(ipv4CIDR: "8.8.8.0/24"), - source: cidrSource), + action: .direct, match: try RuleMatch(ipv4CIDR: "8.8.8.0/24")), ] } diff --git a/ShadowsocksX-NG2/Tests/Smoke/RealSslocalSmokeTests+CustomRules.swift b/ShadowsocksX-NG2/Tests/Smoke/RealSslocalSmokeTests+CustomRules.swift index dae2f23e..041ff8be 100644 --- a/ShadowsocksX-NG2/Tests/Smoke/RealSslocalSmokeTests+CustomRules.swift +++ b/ShadowsocksX-NG2/Tests/Smoke/RealSslocalSmokeTests+CustomRules.swift @@ -12,18 +12,13 @@ extension RealSslocalSmokeTests { let selectedPorts = try grabThreeListenPorts(excluding: [echoServer.port, fakeSSServer.port]) let listen = SslocalListenSettings( socksPort: selectedPorts[0], httpPort: selectedPorts[1]) - let customSource = RuleSourceIdentity( - kind: .custom, upstreamVersion: "user", label: "自定义") let customRules = [ ProxyRule( - action: .direct, match: try RuleMatch(domainSuffix: "direct.example"), - source: customSource), + action: .direct, match: try RuleMatch(domainSuffix: "direct.example")), ProxyRule( - action: .direct, match: try RuleMatch(domainExact: "exact.direct.example"), - source: customSource), + action: .direct, match: try RuleMatch(domainExact: "exact.direct.example")), ProxyRule( - action: .direct, match: try RuleMatch(ipv4CIDR: "203.0.113.0/24"), - source: customSource), + action: .direct, match: try RuleMatch(ipv4CIDR: "203.0.113.0/24")), ] let document = SslocalRuntimeDocument( servers: [ @@ -115,12 +110,9 @@ extension RealSslocalSmokeTests { let selectedPorts = try grabThreeListenPorts(excluding: [echoServer.port, fakeSSServer.port]) let listen = SslocalListenSettings( socksPort: selectedPorts[0], httpPort: selectedPorts[1]) - let customSource = RuleSourceIdentity( - kind: .custom, upstreamVersion: "user", label: "自定义") let customRules = [ ProxyRule( - action: .proxy, match: try RuleMatch(domainSuffix: "blocked.example"), - source: customSource) + action: .proxy, match: try RuleMatch(domainSuffix: "blocked.example")) ] let document = SslocalRuntimeDocument( servers: [ diff --git a/ShadowsocksX-NG2/Tests/Smoke/RealSslocalSmokeTests+GFWListACL.swift b/ShadowsocksX-NG2/Tests/Smoke/RealSslocalSmokeTests+GFWListACL.swift index aab17575..861e09d6 100644 --- a/ShadowsocksX-NG2/Tests/Smoke/RealSslocalSmokeTests+GFWListACL.swift +++ b/ShadowsocksX-NG2/Tests/Smoke/RealSslocalSmokeTests+GFWListACL.swift @@ -12,15 +12,11 @@ extension RealSslocalSmokeTests { let selectedPorts = try grabThreeListenPorts(excluding: [echoServer.port, fakeSSServer.port]) let listen = SslocalListenSettings( socksPort: selectedPorts[0], httpPort: selectedPorts[1]) - let gfwSource = RuleSourceIdentity( - kind: .gfwlist, upstreamVersion: "test", label: "GFWList") let gfwRules = [ ProxyRule( - action: .proxy, match: try RuleMatch(domainSuffix: "blocked.example"), - source: gfwSource), + action: .proxy, match: try RuleMatch(domainSuffix: "blocked.example")), ProxyRule( - action: .proxy, match: try RuleMatch(domainSuffix: "cdn.blocked.example"), - source: gfwSource), + action: .proxy, match: try RuleMatch(domainSuffix: "cdn.blocked.example")), ] let document = SslocalRuntimeDocument( servers: [