[PR #4904] [MERGED] feat(Clash): Add routing rules and enable routing option for Clash subscriptions #5745

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/4904
Author: @Misfit-s
Created: 6/4/2026
Status: ✅ Merged
Merged: 6/4/2026
Merged by: @MHSanaei

Base: main ← Head: main


📝 Commits (3)

  • 8f48f5d feat(clash): add routing rules and enable routing option for Clash/Mihomo subscriptions
  • 30ba1f4 Merge branch 'main' into main
  • 354d142 fix

📊 Changes

24 files changed (+212 additions, -15 deletions)

View changed files

📝 frontend/src/generated/types.ts (+4 -0)
📝 frontend/src/generated/zod.ts (+4 -0)
📝 frontend/src/models/setting.ts (+2 -0)
📝 frontend/src/pages/api-docs/endpoints.ts (+1 -1)
📝 frontend/src/pages/settings/SubscriptionGeneralTab.tsx (+14 -0)
📝 frontend/src/schemas/setting.ts (+2 -0)
📝 sub/sub.go (+11 -1)
📝 sub/subClashService.go (+107 -12)
📝 sub/subController.go (+3 -1)
📝 web/entity/entity.go (+2 -0)
📝 web/service/setting.go (+10 -0)
📝 web/translation/ar-EG.json (+4 -0)
📝 web/translation/en-US.json (+4 -0)
📝 web/translation/es-ES.json (+4 -0)
📝 web/translation/fa-IR.json (+4 -0)
📝 web/translation/id-ID.json (+4 -0)
📝 web/translation/ja-JP.json (+4 -0)
📝 web/translation/pt-BR.json (+4 -0)
📝 web/translation/ru-RU.json (+4 -0)
📝 web/translation/tr-TR.json (+4 -0)

...and 4 more files

📄 Description

Summary

Adds a new configuration block to enable, disable, and customize Clash/Mihomo routing rules, positioned directly below the existing Happ routing settings field in the panel.

Why

Managing client-side routing manually across a large number of clients is not scalable. By adding automated Clash/Mihomo configuration exports, administrators can easily push routing rules to all clients at once. This shifts the routing decisions to the client side, preventing unnecessary traffic, reducing server CPU/bandwidth load, and protecting the server IP from being exposed during handshakes for traffic that should be DIRECT.

Related: #4404

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?

  1. Panel Configuration:

    • Started the panel and ensured Clash/Mihomo configuration support is enabled for users.
    • Navigated to Panel Settings -> Subscription -> Information and scrolled to the bottom.
    • Located the new Clash/Mihomo routing settings block and toggled it ON.
    • Entered a sample routing rule into the text area: DOMAIN,ipinfo.io,DIRECT.
  2. Client-Side Verification:

    • Created a new inbound and added a user client to it.
    • Copied the client's Clash/Mihomo subscription link and imported it into a Clash client app (e.g., Koala-Clash).
    • Verified that the custom routing rules were automatically fetched and applied within the client configuration.
  3. Reactivity & Toggle Test:

    • Changed the rules and toggled the feature OFF in the panel settings.
    • Restarted the panel.
    • Refreshed/updated the subscription inside the Clash client app to confirm that the changes dynamically sync and reflect on the client side.

Screenshots / recordings

UI changes screenshot

Breaking changes

None.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 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/4904 **Author:** [@Misfit-s](https://github.com/Misfit-s) **Created:** 6/4/2026 **Status:** ✅ Merged **Merged:** 6/4/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (3) - [`8f48f5d`](https://github.com/MHSanaei/3x-ui/commit/8f48f5dd1c55c1f9712fd1ed4d0d8f120217c878) feat(clash): add routing rules and enable routing option for Clash/Mihomo subscriptions - [`30ba1f4`](https://github.com/MHSanaei/3x-ui/commit/30ba1f416b9ff4d950b67c45b38222fa471e1b85) Merge branch 'main' into main - [`354d142`](https://github.com/MHSanaei/3x-ui/commit/354d1428604c5ad786b3101a6efd3bc886b51047) fix ### 📊 Changes **24 files changed** (+212 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/generated/types.ts` (+4 -0) 📝 `frontend/src/generated/zod.ts` (+4 -0) 📝 `frontend/src/models/setting.ts` (+2 -0) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+1 -1) 📝 `frontend/src/pages/settings/SubscriptionGeneralTab.tsx` (+14 -0) 📝 `frontend/src/schemas/setting.ts` (+2 -0) 📝 `sub/sub.go` (+11 -1) 📝 `sub/subClashService.go` (+107 -12) 📝 `sub/subController.go` (+3 -1) 📝 `web/entity/entity.go` (+2 -0) 📝 `web/service/setting.go` (+10 -0) 📝 `web/translation/ar-EG.json` (+4 -0) 📝 `web/translation/en-US.json` (+4 -0) 📝 `web/translation/es-ES.json` (+4 -0) 📝 `web/translation/fa-IR.json` (+4 -0) 📝 `web/translation/id-ID.json` (+4 -0) 📝 `web/translation/ja-JP.json` (+4 -0) 📝 `web/translation/pt-BR.json` (+4 -0) 📝 `web/translation/ru-RU.json` (+4 -0) 📝 `web/translation/tr-TR.json` (+4 -0) _...and 4 more files_ </details> ### 📄 Description ## Summary Adds a new configuration block to enable, disable, and customize Clash/Mihomo routing rules, positioned directly below the existing Happ routing settings field in the panel. ## Why Managing client-side routing manually across a large number of clients is not scalable. By adding automated Clash/Mihomo configuration exports, administrators can easily push routing rules to all clients at once. This shifts the routing decisions to the client side, preventing unnecessary traffic, reducing server CPU/bandwidth load, and protecting the server IP from being exposed during handshakes for traffic that should be `DIRECT`. Related: #4404 ## Type of change - [ ] Bug fix - [X] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [X] Frontend (UI / panel pages) - [X] Backend (API endpoints, login, settings) - [ ] Xray config generation - [X] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [X] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? 1. **Panel Configuration:** * Started the panel and ensured Clash/Mihomo configuration support is enabled for users. * Navigated to **Panel Settings** -> **Subscription** -> **Information** and scrolled to the bottom. * Located the new Clash/Mihomo routing settings block and toggled it ON. * Entered a sample routing rule into the text area: `DOMAIN,ipinfo.io,DIRECT`. 2. **Client-Side Verification:** * Created a new inbound and added a user client to it. * Copied the client's Clash/Mihomo subscription link and imported it into a Clash client app (e.g., Koala-Clash). * Verified that the custom routing rules were automatically fetched and applied within the client configuration. 3. **Reactivity & Toggle Test:** * Changed the rules and toggled the feature OFF in the panel settings. * Restarted the panel. * Refreshed/updated the subscription inside the Clash client app to confirm that the changes dynamically sync and reflect on the client side. ## Screenshots / recordings <img width="939" height="789" alt="UI changes screenshot" src="https://github.com/user-attachments/assets/4c4fe371-a5d9-43a8-b807-47860a901a62" /> ## Breaking changes None. ## Checklist - [X] I tested the change locally and confirmed the described behavior. - [ ] I added or updated tests for the new behavior (when applicable). - [X] `go build ./...` and the test suite pass locally. - [X] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [X] I updated the Wiki / README / API docs if user-facing behavior changed. - [X] My commits follow the project's existing message style. - [X] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:03:46 +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#5745
No description provided.