[PR #6168] [MERGED] Add remote routing URL support #6130

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6168
Author: @yelloduxx
Created: 8/1/2026
Status: ✅ Merged
Merged: 8/18/2026
Merged by: @MHSanaei

Base: main ← Head: agent/routing-url-sources


📝 Commits (4)

  • ce3634f Add remote routing URL support
  • 7144ab9 Harden remote routing refresh
  • f8b315a Merge branch 'main' into agent/routing-url-sources
  • 7018a85 fix(sub): harden remote routing fetch and accept Mihomo src rule flag

📊 Changes

25 files changed (+1835 additions, -54 deletions)

View changed files

📝 frontend/src/pages/settings/SubscriptionGeneralTab.tsx (+13 -7)
📝 internal/sub/clash_service.go (+250 -2)
📝 internal/sub/controller.go (+10 -5)
➕ internal/sub/remote_routing.go (+623 -0)
➕ internal/sub/remote_routing_test.go (+750 -0)
📝 internal/util/common/url.go (+27 -1)
📝 internal/util/common/url_test.go (+26 -0)
📝 internal/web/cadence_test.go (+1 -0)
➕ internal/web/job/remote_routing_job.go (+31 -0)
📝 internal/web/service/setting.go (+20 -0)
➕ internal/web/service/setting_remote_routing_test.go (+38 -0)
📝 internal/web/translation/ar-EG.json (+3 -3)
📝 internal/web/translation/en-US.json (+3 -3)
📝 internal/web/translation/es-ES.json (+3 -3)
📝 internal/web/translation/fa-IR.json (+3 -3)
📝 internal/web/translation/id-ID.json (+3 -3)
📝 internal/web/translation/ja-JP.json (+3 -3)
📝 internal/web/translation/pt-BR.json (+3 -3)
📝 internal/web/translation/ru-RU.json (+3 -3)
📝 internal/web/translation/tr-TR.json (+3 -3)

...and 5 more files

📄 Description

What

  • Treat exactly one absolute HTTPS value in the existing Happ and Clash/Mihomo routing fields as a remote routing source while preserving every other value as legacy inline content.
  • Refresh remote sources on panel startup and every five minutes; subscription requests only read validated memory/persisted cache and never wait for network or SQLite loading.
  • Keep a 10-minute last-known-good cache with a 30-second failure retry delay, request coalescing, ETag/Last-Modified support, and persisted restart recovery.
  • Convert an HTTPS Incy routing source to its native incy://autorouting/onadd/<URL> deeplink, so Incy performs its own periodic refresh.
  • Merge only proxy-groups, rule-providers, and rules from remote Clash/Mihomo documents; preserve panel-generated proxies and reject dangling group/provider/rule references.
  • Validate remote URL settings at save time and update the existing settings guidance in all shipped locales.

Why

The routing fields currently accept only materialized rules/deeplinks. That makes permanent upstream routing URLs unusable without a separate updater or a deployment-specific module.

Compatibility and security

  • Existing inline routing values retain their previous behavior, including independent Routing-Enable and Routing headers.
  • Cold-cache requests fail closed by omitting an unavailable remote payload; stale-cache requests return the last validated value immediately while refresh runs in the background.
  • HTTPS fetches use the existing SSRF-guarded dialer, constrained redirects, TLS 1.2+, a six-second background timeout, response-size limits, and no URL credentials.
  • Happ responses are limited to 16 KiB before normalization and 8 KiB for the final Routing header value.
  • Remote Clash content cannot replace generated proxies, import proxy-providers, or change listeners, LAN exposure, DNS, TUN, sniffing, controllers, or authentication.
  • No deployment-specific URLs, server addresses, subscription identifiers, credentials, or private data are included.

Checks

  • go test ./...
  • go test -race ./internal/sub
  • npm run lint
  • npm run typecheck
  • npm run build
  • npm test -- --project unit --project components (986 tests)
  • git diff --check
  • Current RoscomVPN Mihomo routing contract: 9 groups, 26 rule providers, and 31 rules accepted while standalone-client keys and the manual proxy-provider placeholder are dropped.
  • Deployment smoke test across restart: Happ, Mihomo, Incy, and JSON subscriptions returned successfully; the generated Mihomo YAML passed official Mihomo 1.19.29 validation; persisted cache timestamps and content remained unchanged inside TTL.

🔄 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/6168 **Author:** [@yelloduxx](https://github.com/yelloduxx) **Created:** 8/1/2026 **Status:** ✅ Merged **Merged:** 8/18/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `agent/routing-url-sources` --- ### 📝 Commits (4) - [`ce3634f`](https://github.com/MHSanaei/3x-ui/commit/ce3634f37a6305e402bda605eebbba2aab384415) Add remote routing URL support - [`7144ab9`](https://github.com/MHSanaei/3x-ui/commit/7144ab964cd5d58098833307e5692fb8e069f464) Harden remote routing refresh - [`f8b315a`](https://github.com/MHSanaei/3x-ui/commit/f8b315a2fd52317fed4d9abf20bd118b896f9c07) Merge branch 'main' into agent/routing-url-sources - [`7018a85`](https://github.com/MHSanaei/3x-ui/commit/7018a85f7ba099eca025adc2c9f920b2d39dd868) fix(sub): harden remote routing fetch and accept Mihomo src rule flag ### 📊 Changes **25 files changed** (+1835 additions, -54 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/pages/settings/SubscriptionGeneralTab.tsx` (+13 -7) 📝 `internal/sub/clash_service.go` (+250 -2) 📝 `internal/sub/controller.go` (+10 -5) ➕ `internal/sub/remote_routing.go` (+623 -0) ➕ `internal/sub/remote_routing_test.go` (+750 -0) 📝 `internal/util/common/url.go` (+27 -1) 📝 `internal/util/common/url_test.go` (+26 -0) 📝 `internal/web/cadence_test.go` (+1 -0) ➕ `internal/web/job/remote_routing_job.go` (+31 -0) 📝 `internal/web/service/setting.go` (+20 -0) ➕ `internal/web/service/setting_remote_routing_test.go` (+38 -0) 📝 `internal/web/translation/ar-EG.json` (+3 -3) 📝 `internal/web/translation/en-US.json` (+3 -3) 📝 `internal/web/translation/es-ES.json` (+3 -3) 📝 `internal/web/translation/fa-IR.json` (+3 -3) 📝 `internal/web/translation/id-ID.json` (+3 -3) 📝 `internal/web/translation/ja-JP.json` (+3 -3) 📝 `internal/web/translation/pt-BR.json` (+3 -3) 📝 `internal/web/translation/ru-RU.json` (+3 -3) 📝 `internal/web/translation/tr-TR.json` (+3 -3) _...and 5 more files_ </details> ### 📄 Description ## What - Treat exactly one absolute HTTPS value in the existing Happ and Clash/Mihomo routing fields as a remote routing source while preserving every other value as legacy inline content. - Refresh remote sources on panel startup and every five minutes; subscription requests only read validated memory/persisted cache and never wait for network or SQLite loading. - Keep a 10-minute last-known-good cache with a 30-second failure retry delay, request coalescing, ETag/Last-Modified support, and persisted restart recovery. - Convert an HTTPS Incy routing source to its native [`incy://autorouting/onadd/<URL>`](https://docs.incy.cc/en/autorouting/) deeplink, so Incy performs its own periodic refresh. - Merge only `proxy-groups`, `rule-providers`, and `rules` from remote Clash/Mihomo documents; preserve panel-generated proxies and reject dangling group/provider/rule references. - Validate remote URL settings at save time and update the existing settings guidance in all shipped locales. ## Why The routing fields currently accept only materialized rules/deeplinks. That makes permanent upstream routing URLs unusable without a separate updater or a deployment-specific module. ## Compatibility and security - Existing inline routing values retain their previous behavior, including independent `Routing-Enable` and `Routing` headers. - Cold-cache requests fail closed by omitting an unavailable remote payload; stale-cache requests return the last validated value immediately while refresh runs in the background. - HTTPS fetches use the existing SSRF-guarded dialer, constrained redirects, TLS 1.2+, a six-second background timeout, response-size limits, and no URL credentials. - Happ responses are limited to 16 KiB before normalization and 8 KiB for the final `Routing` header value. - Remote Clash content cannot replace generated proxies, import `proxy-providers`, or change listeners, LAN exposure, DNS, TUN, sniffing, controllers, or authentication. - No deployment-specific URLs, server addresses, subscription identifiers, credentials, or private data are included. ## Checks - `go test ./...` - `go test -race ./internal/sub` - `npm run lint` - `npm run typecheck` - `npm run build` - `npm test -- --project unit --project components` (986 tests) - `git diff --check` - Current RoscomVPN Mihomo routing contract: 9 groups, 26 rule providers, and 31 rules accepted while standalone-client keys and the manual proxy-provider placeholder are dropped. - Deployment smoke test across restart: Happ, Mihomo, Incy, and JSON subscriptions returned successfully; the generated Mihomo YAML passed official Mihomo 1.19.29 validation; persisted cache timestamps and content remained unchanged inside TTL. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:34 +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#6130
No description provided.