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', + ]); + } } /**