[PR #6338] [MERGED] feat(sub): add legacy Clash subscription endpoint #6224

Closed
opened 2026-11-02 04:07:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6338
Author: @duqigit
Created: 8/27/2026
Status: ✅ Merged
Merged: 9/10/2026
Merged by: @MHSanaei

Base: main ← Head: feature/add-clash-legacy-subscription


📝 Commits (5)

  • e29c271 feat(sub): add legacy Clash subscription endpoint
  • b0778b0 fix(deps): update js-yaml to patched release
  • ff63793 fix(sub): preserve client detection and normalize legacy cipher
  • cc58a26 Merge branch 'main' into feature/add-clash-legacy-subscription
  • d98ca8f refactor(sub): drop an unreachable guard and make the alias test assert

📊 Changes

6 files changed (+520 additions, -16 deletions)

View changed files

📝 docs/content/docs/en/config/subscription.mdx (+26 -5)
📝 docs/content/docs/zh/config/subscription.mdx (+22 -5)
📝 internal/sub/clash_service.go (+115 -1)
📝 internal/sub/clash_service_test.go (+79 -0)
📝 internal/sub/controller.go (+62 -5)
📝 internal/sub/controller_test.go (+216 -0)

📄 Description

Summary

Adds explicit Mihomo and legacy Clash for Windows subscription endpoints while preserving the existing /clash/<sub-id> behavior and default User-Agent detection. The legacy endpoint filters unsupported proxies and configuration syntax before generating YAML.

Why

Legacy Clash for Windows cannot parse modern Mihomo proxy types and options such as VLESS, Hysteria2, Reality, XHTTP, HTTPUpgrade, and Shadowsocks 2022. A subscription containing these entries may fail to import completely.

This change provides:

  • /mihomo/<sub-id> for the full modern Mihomo profile.
  • /clash-legacy/<sub-id> for a conservative Clash for Windows-compatible profile.
  • An explicit 422 response when no compatible proxies are available.
  • Existing (?i)(clash|mihomo) auto-detection remains unchanged; legacy clients use the explicit legacy endpoint.
  • Legacy Shadowsocks output normalizes chacha20-poly1305 to chacha20-ietf-poly1305 instead of dropping a compatible node.
  • Updates the existing js-yaml override and lockfile to 4.3.2 to resolve GHSA-2883-xcg3-v3hh.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

The following test suites passed locally:

go test ./internal/sub -count=1
go test ./internal/web/service -count=1

Regression tests exercise the real subscription HTTP endpoints for Clash/Mihomo User-Agents and both Shadowsocks cipher spellings. Existing custom-regex, incompatible-protocol and legacy-routing tests pass.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6338 **Author:** [@duqigit](https://github.com/duqigit) **Created:** 8/27/2026 **Status:** ✅ Merged **Merged:** 9/10/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feature/add-clash-legacy-subscription` --- ### 📝 Commits (5) - [`e29c271`](https://github.com/MHSanaei/3x-ui/commit/e29c27151f5de7bffbe7b5ab448d4df81cc3524e) feat(sub): add legacy Clash subscription endpoint - [`b0778b0`](https://github.com/MHSanaei/3x-ui/commit/b0778b0373f111b1a1b28abfda6d05b4e68e1a0b) fix(deps): update js-yaml to patched release - [`ff63793`](https://github.com/MHSanaei/3x-ui/commit/ff63793dcf24ddce905fd07ea0edc35f47bac888) fix(sub): preserve client detection and normalize legacy cipher - [`cc58a26`](https://github.com/MHSanaei/3x-ui/commit/cc58a26395a5eb19ef691690fad175a9a956e6ad) Merge branch 'main' into feature/add-clash-legacy-subscription - [`d98ca8f`](https://github.com/MHSanaei/3x-ui/commit/d98ca8fd4ecc8b9967915d87098344b2d7a501bb) refactor(sub): drop an unreachable guard and make the alias test assert ### 📊 Changes **6 files changed** (+520 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/config/subscription.mdx` (+26 -5) 📝 `docs/content/docs/zh/config/subscription.mdx` (+22 -5) 📝 `internal/sub/clash_service.go` (+115 -1) 📝 `internal/sub/clash_service_test.go` (+79 -0) 📝 `internal/sub/controller.go` (+62 -5) 📝 `internal/sub/controller_test.go` (+216 -0) </details> ### 📄 Description ## Summary Adds explicit Mihomo and legacy Clash for Windows subscription endpoints while preserving the existing `/clash/<sub-id>` behavior and default User-Agent detection. The legacy endpoint filters unsupported proxies and configuration syntax before generating YAML. ## Why Legacy Clash for Windows cannot parse modern Mihomo proxy types and options such as VLESS, Hysteria2, Reality, XHTTP, HTTPUpgrade, and Shadowsocks 2022. A subscription containing these entries may fail to import completely. This change provides: - `/mihomo/<sub-id>` for the full modern Mihomo profile. - `/clash-legacy/<sub-id>` for a conservative Clash for Windows-compatible profile. - An explicit `422` response when no compatible proxies are available. - Existing `(?i)(clash|mihomo)` auto-detection remains unchanged; legacy clients use the explicit legacy endpoint. - Legacy Shadowsocks output normalizes `chacha20-poly1305` to `chacha20-ietf-poly1305` instead of dropping a compatible node. - Updates the existing js-yaml override and lockfile to 4.3.2 to resolve GHSA-2883-xcg3-v3hh. ## Type of change - [x] Bug fix - [x] New feature - [ ] Refactoring (no behavior change) - [x] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [ ] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [ ] Xray config generation - [x] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? The following test suites passed locally: ```bash go test ./internal/sub -count=1 go test ./internal/web/service -count=1 ``` Regression tests exercise the real subscription HTTP endpoints for Clash/Mihomo User-Agents and both Shadowsocks cipher spellings. Existing custom-regex, incompatible-protocol and legacy-routing tests pass. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:07:14 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6224
No description provided.