Skip to content

feat: 支持 AnyTLS URI 订阅解析与生成 - #416

Open
luodaoyi wants to merge 1 commit into
7Sageer:mainfrom
luodaoyi:feat/anytls-uri-support
Open

feat: 支持 AnyTLS URI 订阅解析与生成#416
luodaoyi wants to merge 1 commit into
7Sageer:mainfrom
luodaoyi:feat/anytls-uri-support

Conversation

@luodaoyi

@luodaoyi luodaoyi commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

背景

项目已经能从 Clash YAML / sing-box JSON 中读取 type: anytls,Clash builder 也已有 AnyTLS 输出分支,但 ProxyParser 没有注册 anytls:// URI parser。因此普通 URI 列表、远程 URI 订阅和 Base64 URI 订阅中的 AnyTLS 节点会在进入 builder 前返回 undefined 并被静默丢弃。

本 PR 参考了 #374#405 的正确方向,但将改动收敛为 AnyTLS 所需的 5 个文件,排除 README、Loon、规则 URL 等无关变更,并补齐协议边界和端到端测试。

实现

  • 新增并注册 anytls:// parser。
  • 遵循 AnyTLS 官方 URI 规范
    • userinfo 密码及百分号解码;
    • hostname / IPv6 authority;
    • 省略端口时默认 443
    • sniinsecure=0/1
    • fragment 节点名及百分号解码。
  • URI 没有 fragment 时生成稳定的 AnyTLS host:port 名称,避免节点因空 tag 再次被过滤。
  • 兼容常见客户端扩展:fp / fingerprint、ALPN、UDP、idle-session 参数及常见别名。
  • URI scheme 按 RFC 语义大小写不敏感。
  • 在 Mihomo kebab-case 与 sing-box snake_case 之间转换三个 idle-session 选项:
    • idle-session-check-intervalidle_session_check_interval
    • idle-session-timeoutidle_session_timeout
    • min-idle-sessionmin_idle_session
  • Sing-box 输出继续移除 Clash-only 的 udp 字段;Clash 输出默认保留 UDP 能力。

覆盖场景

新增 7 个 AnyTLS 回归场景:

  1. 官方 URI 字段、编码密码及兼容扩展;
  2. 默认端口与无 fragment 链接;
  3. IPv6 authority 与编码节点名;
  4. 通用 ProxyParser 注册及大小写 scheme;
  5. 远程 URI 订阅生成 Clash/Mihomo 配置;
  6. Base64 URI 订阅生成原生 sing-box 配置;
  7. sing-box JSON 转 Clash 时的 session 字段映射。

验证

  • AnyTLS/YAML/UDP 定向测试:22/22 通过。

  • 全量 Vitest:229/229 通过。

  • npm run build:Vercel 构建通过。

  • git diff --check、UTF-8/CRLF 检查通过。

  • 官方 PR Test Worker 通过:run 30545291444

  • 官方 PR Docker 双架构构建通过:run 30545291087

  • Vercel 在构建前返回 Authorization required to deploy,属于 fork 作者缺少上游 Vercel 团队授权;本地 npm run build 已通过。

合并建议

建议合并这一聚焦版本:它修复了 AnyTLS 节点丢失的实际根因,同时覆盖官方 URI 边界、远程/Base64 订阅和两个目标格式,不携带 #374/#405 中缺测或无关的大范围改动。

Register an AnyTLS URI parser so plain, remote, and Base64 subscription lists no longer drop anytls:// nodes before they reach the configuration builders.

Follow the official AnyTLS URI fields for encoded passwords, default port 443, SNI, insecure mode, IPv6, and display fragments while accepting common client extensions for fingerprint, ALPN, UDP, and idle-session options.

Normalize idle-session option names for Mihomo and sing-box outputs and add end-to-end regression coverage for parser dispatch, remote subscriptions, Base64 input, and both generated formats.
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

@myassistantChatGPT is attempting to deploy a commit to the 7sageer's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

2 participants