Scope proxy-group selections per subscription and retire selectedNode - #105
Merged
Conversation
`selectedNode` held ONE global node name that the main app pushed into every non-bypass Selector group at tunnel start, and that `ConfigManager.applySelectedNode()` also promoted to index 0 of every such group in the effective YAML. Nothing has written that key since node selection moved to the REST API (#23), so the only values still in the wild are leftovers from older builds — a node name from a subscription the user may no longer even have. When that stale name also existed in the current subscription it passed the `all.contains(name)` membership check and got pinned into every group, routing all traffic through a node the user never picked. Observed with a leftover "Taiwan 05" whose entry host was down: every group black-holed and it looked like the app couldn't handle the subscription at all. It also raced `replaySelectionsToEngine()` and won (2s delay), so real per-group choices were overwritten on every connect. `applySelectedNode()` was lossy on top of that: it round-tripped proxy-groups through the editable parser, which only understands name/type/proxies/url/interval — so `use:`, `filter:`, `lazy:` and friends were silently dropped, emptying provider-backed groups. The real per-group selections had their own leak: `proxyGroupSelections` was keyed by group name alone, so two subscriptions sharing a group name and a node name replayed each other's picks (issue #75 item 6). - Add `Shared/ProxyGroupSelections.swift`: selections keyed by subscription scope first, group name second, stored as a plist dictionary. Migrates the legacy unscoped blob into the active subscription and deletes `selectedNode` outright. - Replace `selectSavedProxyNode()` with `replaySavedGroupSelections()`, which pushes only groups the user chose in, only with a value the group still lists. - Drop `applySelectedNode()` entirely — no config-time group rewriting. - `updateGlobalProxyGroup` / `syncGlobalSelector` use the user's own GLOBAL selection, and only when this config still defines that name. - Swap scopes on subscription switch; forget a deleted subscription's scope. - Drop `firstBypassMember`, now unused.
This was referenced Aug 27, 2026
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.
The bug
selectedNodeheld one global node name that the main app pushed into every non-bypassSelectorgroup at tunnel start, and thatConfigManager.applySelectedNode()also promoted to index 0 of every such group in the effective YAML.Nothing has written that key since node selection moved to the REST API (#23) — so the only values still in the wild are leftovers from older builds, a node name from a subscription the user may no longer even have.
When that stale name also existed in the current subscription, it passed the
all.contains(name)membership check and got pinned into every group, routing all traffic through a node the user never picked. Observed with a leftover🇨🇳 Taiwan 05whose entry host was down: all 22 groups black-holed and it looked like the app couldn't handle the subscription at all, while the same config worked in standalonemeow-rs(where a live node had been picked by hand).It also raced
replaySelectionsToEngine()and won — the global push runs on a 2s delay — so the user's real per-group choices were overwritten on every connect.Two more issues in the same path
applySelectedNode()was lossy. It round-trippedproxy-groupsthrough the editable parser, which only understandsname/type/proxies/url/interval.use:,filter:,lazy:,tolerance:and friends were silently dropped — emptying provider-backed groups for exactly the users who had the legacy key set.TODO(#75)item 6 inProxyGroupsViewModel).proxyGroupSelectionswas keyed by group name alone, so two subscriptions sharing a group name and a node name replayed each other's picks.The fix
Shared/ProxyGroupSelections.swift— selections keyed by subscription scope first, group name second. Stored as a plist dictionary (sodefaultscan still read/write it, which the E2E scripts rely on). Migrates the legacy unscoped blob into the active subscription and deletesselectedNodeoutright so it can never be pushed into a group again.selectSavedProxyNode()→replaySavedGroupSelections(): pushes only groups the user actually chose in, only with a value the group still lists. Engine-managed groups (URLTest, Fallback, …) are never pinned.applySelectedNode()removed — no config-time group rewriting at all. The engine starts each group on the config's own first member and the REST replay restores the user's choices, which is already how every post-Refactor proxy group management to use REST API #23 install behaves.updateGlobalProxyGroup/syncGlobalSelectoruse the user's ownGLOBALselection, and only when this config still defines that name (newconfigDefinesProxyNameguard) — previously a stale name was listed blindly and the engine silently dropped it.firstBypassMemberdropped (its only callers are gone) along with its test suite; the shared recursion stays covered by theisBypassGrouptests.Testing
swiftlint lint --strict— 0 violations.xcodebuild test -only-testing:BaoLianDengTests— 213 tests, all pass exceptHTTP request through SOCKS5 proxy, which fails identically onmain(network-dependent, curl exit 28).ProxyGroupSelectionsTestscovers scoping, scope removal, both legacy migrations, and malformed storage.selectedNode.