From f5106e3b947aa122ee7df5e03a243c2b9fcc2147 Mon Sep 17 00:00:00 2001 From: daidaidaiok Date: Sun, 10 May 2026 13:30:51 +0800 Subject: [PATCH] fix(SingBox): inject DIRECT route rule for panel domain The buildRule() method previously read the configured rules and wrote them back unchanged, leaving an empty hook. As a result, sing-box / hiddify / sfm users who import the subscription have the panel host routed through their proxy outbound, frequently making the panel unreachable when the outbound cannot reach the panel's origin IP. Mirror the existing behaviour from Clash / ClashMeta / Stash protocols: unshift a {domain: [host], outbound: direct} rule at the head of route.rules so the panel host always bypasses the proxy. --- app/Protocols/SingBox.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Protocols/SingBox.php b/app/Protocols/SingBox.php index ff7e653e4..e18ad24e7 100644 --- a/app/Protocols/SingBox.php +++ b/app/Protocols/SingBox.php @@ -304,11 +304,21 @@ protected function resolveFallback($fallback, array $allTags, array $outbounds, /** * Build rule + * + * Inject a DIRECT route rule for the current subscription (panel) host so that + * users importing the subscription do not lose access to the panel through their + * proxy outbound. Mirrors the behaviour already implemented in Clash / ClashMeta + * / Stash protocols. */ protected function buildRule() { - $rules = $this->config['route']['rules']; - $this->config['route']['rules'] = $rules; + $subsDomain = request()->header('Host'); + if ($subsDomain && isset($this->config['route']['rules']) && is_array($this->config['route']['rules'])) { + array_unshift($this->config['route']['rules'], [ + 'domain' => [$subsDomain], + 'outbound' => 'direct', + ]); + } } /**