From 3a27c1c169505906e89a08f7a3e998e784edd2af Mon Sep 17 00:00:00 2001 From: Eugene Stsefankou <44508449+stefjen07@users.noreply.github.com> Date: Tue, 24 Nov 2026 20:10:23 +0900 Subject: [PATCH] feat(sub): serve Clash/Mihomo YAML to the Rabbit-Hole client (#7063) RabbitHole runs a Mihomo core and sends a Rabbit-Hole/ User-Agent. The default matcher only knew clash and mihomo, so with automatic format detection on it received the raw link list. Add rabbit-hole to the default Clash/Mihomo User-Agent regex. A panel with its own regex is unaffected. The client's User-Agent joins the auto-serve test table, and the settings placeholder and subscription docs show the new default. --- docs/content/docs/en/config/subscription.mdx | 4 ++-- docs/content/docs/zh/config/subscription.mdx | 2 +- frontend/src/pages/settings/SubscriptionFormatsTab.tsx | 2 +- internal/sub/controller_test.go | 1 + internal/web/service/setting.go | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/content/docs/en/config/subscription.mdx b/docs/content/docs/en/config/subscription.mdx index f22d74653..3de0ed322 100644 --- a/docs/content/docs/en/config/subscription.mdx +++ b/docs/content/docs/en/config/subscription.mdx @@ -69,8 +69,8 @@ If an administrator has already assigned `/mihomo/` or `/clash-legacy/` to a different configurable subscription path, that existing path is preserved and the conflicting alias is skipped with a warning at startup. -Automatic Clash format detection keeps the existing `(?i)(clash|mihomo)` -default matcher so existing subscription URLs continue returning YAML. +Automatic Clash format detection defaults to the `(?i)(clash|mihomo|rabbit-hole)` +matcher, so existing subscription URLs continue returning YAML. It does not distinguish legacy clients from Mihomo-based clients; Clash for Windows users must use `/clash-legacy/` for a compatible profile. diff --git a/docs/content/docs/zh/config/subscription.mdx b/docs/content/docs/zh/config/subscription.mdx index 56b37221b..498f944bf 100644 --- a/docs/content/docs/zh/config/subscription.mdx +++ b/docs/content/docs/zh/config/subscription.mdx @@ -57,7 +57,7 @@ Shadowsocks 节点,并排除 VLESS、Hysteria2、Reality、XHTTP、HTTPUpgrade 如果管理员已经把 `/mihomo/` 或 `/clash-legacy/` 分配给其他可配置订阅路径, 系统会保留原有路径,并在启动时记录警告、跳过发生冲突的别名。 -Clash 格式自动识别保留原有的 `(?i)(clash|mihomo)` 默认匹配器,确保已有订阅 URL +Clash 格式自动识别默认使用 `(?i)(clash|mihomo|rabbit-hole)` 匹配器,确保已有订阅 URL 继续返回 YAML。它不区分旧版客户端与 Mihomo 系客户端;Clash for Windows 用户 必须使用 `/clash-legacy/` 获取兼容配置。 diff --git a/frontend/src/pages/settings/SubscriptionFormatsTab.tsx b/frontend/src/pages/settings/SubscriptionFormatsTab.tsx index b3884bf9d..d88b639e1 100644 --- a/frontend/src/pages/settings/SubscriptionFormatsTab.tsx +++ b/frontend/src/pages/settings/SubscriptionFormatsTab.tsx @@ -314,7 +314,7 @@ export default function SubscriptionFormatsTab({ > updateSetting({ subClashUserAgentRegex: value })} /> diff --git a/internal/sub/controller_test.go b/internal/sub/controller_test.go index cb81205a5..0377e6f6f 100644 --- a/internal/sub/controller_test.go +++ b/internal/sub/controller_test.go @@ -192,6 +192,7 @@ func TestShouldAutoServeClash(t *testing.T) { {name: "clash case insensitive", autoDetect: true, clashEnabled: true, userAgent: "CLASH-META/1.0", want: true}, {name: "flclash covered by clash", autoDetect: true, clashEnabled: true, userAgent: "FlClash/0.8.91", want: true}, {name: "clash for windows preserves existing detection", autoDetect: true, clashEnabled: true, userAgent: "ClashforWindows/0.20.39", want: true}, + {name: "rabbit-hole runs a mihomo core", autoDetect: true, clashEnabled: true, userAgent: "Rabbit-Hole/iOS (1.5.0-207; language en_US)", want: true}, {name: "generic client raw fallback", autoDetect: true, clashEnabled: true, userAgent: "GenericClient/1.10.0"}, {name: "other client raw fallback", autoDetect: true, clashEnabled: true, userAgent: "OtherClient/2.2"}, {name: "unknown raw fallback", autoDetect: true, clashEnabled: true, userAgent: "CustomClient/1.0"}, diff --git a/internal/web/service/setting.go b/internal/web/service/setting.go index b68c5ceda..38a590acc 100644 --- a/internal/web/service/setting.go +++ b/internal/web/service/setting.go @@ -35,7 +35,7 @@ import ( var xrayTemplateConfig string const ( - DefaultSubClashUserAgentRegex = `(?i)(clash|mihomo)` + DefaultSubClashUserAgentRegex = `(?i)(clash|mihomo|rabbit-hole)` DefaultExternalSubUserAgent = "v2rayNG/1.8.5" DefaultSubJsonUserAgentRegex = `` DefaultRemarkTemplate = "{{INBOUND}}-{{EMAIL}}|📊{{TRAFFIC_LEFT}}|⏳{{DAYS_LEFT}}D"