diff --git a/app/Http/Controllers/Client/Protocols/Clash.php b/app/Http/Controllers/Client/Protocols/Clash.php index 23b358d9..dd0cfc24 100644 --- a/app/Http/Controllers/Client/Protocols/Clash.php +++ b/app/Http/Controllers/Client/Protocols/Clash.php @@ -54,6 +54,11 @@ class Clash if (!is_array($config['proxy-groups'][$k]['proxies'])) continue; $config['proxy-groups'][$k]['proxies'] = array_merge($config['proxy-groups'][$k]['proxies'], $proxies); } + // Force the current subscription domain to be a direct rule + $subsDomain = $_SERVER['SERVER_NAME']; + $subsDomainRule = "DOMAIN,{$subsDomain},DIRECT"; + array_unshift($config['rules'], $subsDomainRule); + $yaml = Yaml::dump($config); $yaml = str_replace('$app_name', config('v2board.app_name', 'V2Board'), $yaml); return $yaml; diff --git a/app/Http/Controllers/Client/Protocols/Surfboard.php b/app/Http/Controllers/Client/Protocols/Surfboard.php index 7b8384a6..292c466b 100644 --- a/app/Http/Controllers/Client/Protocols/Surfboard.php +++ b/app/Http/Controllers/Client/Protocols/Surfboard.php @@ -54,8 +54,10 @@ class Surfboard // Subscription link $subsURL = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token']; + $subsDomain = $_SERVER['SERVER_NAME']; $config = str_replace('$subs_link', $subsURL, $config); + $config = str_replace('$subs_domain', $subsDomain, $config); $config = str_replace('$proxies', $proxies, $config); $config = str_replace('$proxy_group', rtrim($proxyGroup, ', '), $config); return $config; diff --git a/app/Http/Controllers/Client/Protocols/Surge.php b/app/Http/Controllers/Client/Protocols/Surge.php index 19f70c5a..b93b1836 100644 --- a/app/Http/Controllers/Client/Protocols/Surge.php +++ b/app/Http/Controllers/Client/Protocols/Surge.php @@ -53,8 +53,10 @@ class Surge // Subscription link $subsURL = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token']; + $subsDomain = $_SERVER['SERVER_NAME']; $config = str_replace('$subs_link', $subsURL, $config); + $config = str_replace('$subs_domain', $subsDomain, $config); $config = str_replace('$proxies', $proxies, $config); $config = str_replace('$proxy_group', rtrim($proxyGroup, ', '), $config); return $config; diff --git a/resources/rules/default.surfboard.conf b/resources/rules/default.surfboard.conf index 69b2446d..7b83d334 100644 --- a/resources/rules/default.surfboard.conf +++ b/resources/rules/default.surfboard.conf @@ -31,6 +31,9 @@ DOMAIN-SUFFIX,naver.com,Proxy DOMAIN-SUFFIX,smartmediarep.com,Proxy DOMAIN-SUFFIX,technews.tw,Proxy +# 强制订阅域名直连 +DOMAIN,$subs_domain,DIRECT + # 实用规则片段集 # RULE-SET,https://cdn.jsdelivr.net/gh/Hackl0us/SS-Rule-Snippet@master/Rulesets/Surge/Basic/Apple-News.list,Proxy RULE-SET,https://cdn.jsdelivr.net/gh/Hackl0us/SS-Rule-Snippet@master/Rulesets/Surge/Basic/Apple-proxy.list,Proxy diff --git a/resources/rules/default.surge.conf b/resources/rules/default.surge.conf index 15352891..be8a06c3 100644 --- a/resources/rules/default.surge.conf +++ b/resources/rules/default.surge.conf @@ -27,6 +27,7 @@ ipv6 = true test-timeout = 4 proxy-test-url = http://www.gstatic.com/generate_204 +geoip-maxmind-url = https://cdn.jsdelivr.net/gh/Hackl0us/GeoIP2-CN@release/Country.mmdb [Replica] hide-apple-request = true @@ -55,6 +56,9 @@ fallback = fallback, $proxy_group, url=http://www.gstatic.com/generate_204, inte # 自定义规则 ## 您可以在此处插入自定义规则 +# 强制订阅域名直连 +DOMAIN,$subs_domain,DIRECT + # 实用规则片段集 # RULE-SET,https://cdn.jsdelivr.net/gh/Hackl0us/SS-Rule-Snippet@master/Rulesets/Surge/Basic/Apple-News.list,Proxy RULE-SET,https://cdn.jsdelivr.net/gh/Hackl0us/SS-Rule-Snippet@master/Rulesets/Surge/Basic/Apple-proxy.list,Proxy