Skip to content

fix(chain): keep proxy chain members whose remarks contain a comma - #6438

Merged
2dust merged 1 commit into
2dust:masterfrom
b84330808:fix-proxy-chain-comma-remarks
Nov 13, 2026
Merged

2dust merged 1 commit into
2dust:masterfrom
b84330808:fix-proxy-chain-comma-remarks

Conversation

@b84330808

@b84330808 b84330808 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6362

A proxy chain stored its members as remarks joined with , in proxyChainProfiles, so a member whose remark contains a comma was split into names that match no profile.

  • New ProfileItem.proxyChainProfileList: List<String>, used by the proxy chain editor, the v2rayN import and connect-time resolution.
  • proxyChainProfiles is kept and marked @Deprecated.
  • A one-time migration in SettingsManager.initApp, next to migrateHysteria2PinSHA256, splits an existing proxyChainProfiles value on , into proxyChainProfileList and clears the old field.

:app:testPlaystoreDebugUnitTest and the Kotlin compile pass on Ubuntu with JDK 21 and the release libv2ray.aar. Not checked on a device.

@2dust

2dust commented Nov 13, 2026

Copy link
Copy Markdown
Owner

感谢
但是这个方案不合理;既然要想解决就彻底一些,

var proxyChainProfiles: String? = null,

改成 下面,且做好数据迁移

var proxyChainProfileList: List<String>? = null,

@b84330808

Copy link
Copy Markdown
Contributor Author

好的,我改成 proxyChainProfileList: List<String>? 并加上旧数据迁移,改好后更新这个 PR。

@b84330808
b84330808 force-pushed the fix-proxy-chain-comma-remarks branch from f04c995 to cb40cdd Compare November 13, 2026 06:34
@b84330808

Copy link
Copy Markdown
Contributor Author

改好了:字段换成 proxyChainProfileList: List,启动时一次性迁移旧的 proxyChainProfiles(含逗号的备注也能正确拆),旧备份还原后也会迁移,麻烦再看看~

@2dust

2dust commented Nov 13, 2026

Copy link
Copy Markdown
Owner

ProxyChainProfiles.kt 删除掉吧,这是个小问题,没有必要多一个文件.
且迁移我们只做正确的数据,错误的数据不管,目前就一个人反馈,让他自己改下就可以了。

var proxyChainProfiles: String? = null, 这个属性不要删除标记为 @deprecated,做迁移的时候方便使用。

Add ProfileItem.proxyChainProfileList: List<String> and use it in the
proxy chain editor, the v2rayN import and connect-time resolution, so a
member remark is stored as one item instead of being joined with ",".

proxyChainProfiles is kept and marked @deprecated. A one-time migration
in SettingsManager.initApp, next to migrateHysteria2PinSHA256, splits an
existing proxyChainProfiles value on "," into proxyChainProfileList and
clears the old field.

Fixes 2dust#6362
@b84330808
b84330808 force-pushed the fix-proxy-chain-comma-remarks branch from cb40cdd to ad9f2e2 Compare November 13, 2026 07:51
@b84330808

Copy link
Copy Markdown
Contributor Author

已按你说的改了:删掉了 ProxyChainProfiles.kt,proxyChainProfiles 保留并标记 @deprecated,迁移只按逗号拆分正常的数据。

@2dust

2dust commented Nov 13, 2026

Copy link
Copy Markdown
Owner

感谢

@2dust
2dust merged commit 141059d into 2dust:master Nov 13, 2026
1 check passed
patterniha added a commit to patterniha/PattNG that referenced this pull request Nov 13, 2026
Upstream 2dust#6438 stores the members of a proxy chain in
proxyChainProfileList instead of the comma-joined proxyChainProfiles,
and its one-time migration splits the old field on every comma. PattNG
already kept a comma or a backslash inside a name in that field,
escaped by a backslash, so upstream's split would cut such a name in
two ("US\, Dallas" became "US\" and "Dallas") and break the chain.

ProfileItem.moveLegacyProxyChain moves a chain into the list as PattNG
wrote it (proxyChainMembersOf: names whole, nothing trimmed) and clears
the old field; SettingsManager's migration uses it.
ProfileItem.proxyChainMembers reads the list, or a chain still stored
the old way, as after a backup of an older PattNG is restored. The
context builder and the chain editor go by it, and the editor saves the
list as upstream's does. The old writer proxyChainProfilesOf is gone.
Both functions that touch the deprecated field carry a function-scoped
suppression and the condition for their removal.

Test:
- CoreConfigContextBuilderTest (the old format read, moved once, read
  where not moved yet; hops found by whole names) and
  ServerProxyChainViewModelTest (the list saved and opened; a chain
  stored the old way opens with its names whole).

Checks:
- Not run: :app:compilePlaystoreDebugKotlin,
  :app:testPlaystoreDebugUnitTest and :app:assemblePlaystoreDebug;
  there is no Android SDK on this machine. The real context builder,
  ProfileItem and the chain, group and subscription editor view models
  were compiled with kotlinc 2.4.10 and their tests run: 30 of 30 and
  45 of 45 pass; with upstream's comma split in the migration, or
  without the old-format fallback, the new tests fail. All main and
  test sources were compiled with the stdlib alone for PattNG before
  the merge, upstream and this tree: no new error but the ServerUiState
  copy() one that is there already, and JUnit names in the new tests.
- Not run on a device: opening, saving and connecting a chain, and the
  migration of chains an older PattNG stored.
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.

链式代理只有两个节点显示成3个的问题

2 participants