mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-14 02:50:52 +08:00
feat: Singbox、clash订阅增加绕过服务器地址规则
1、优化订阅下发代码 2、singbox、clash、meta订阅下发增加绕过服务器地址规则,防止重复代理
This commit is contained in:
@@ -81,11 +81,7 @@ class ClashMeta
|
||||
return $group['proxies'];
|
||||
});
|
||||
$config['proxy-groups'] = array_values($config['proxy-groups']);
|
||||
// Force the current subscription domain to be a direct rule
|
||||
$subsDomain = request()->header('Host');
|
||||
if ($subsDomain) {
|
||||
array_unshift($config['rules'], "DOMAIN,{$subsDomain},DIRECT");
|
||||
}
|
||||
$config = $this->buildRules($config);
|
||||
|
||||
$yaml = Yaml::dump($config, 2, 4, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);
|
||||
$yaml = str_replace('$app_name', admin_setting('app_name', 'XBoard'), $yaml);
|
||||
@@ -95,6 +91,27 @@ class ClashMeta
|
||||
->header('content-disposition', 'attachment;filename*=UTF-8\'\'' . rawurlencode($appName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the rules for Clash.
|
||||
*/
|
||||
public function buildRules($config)
|
||||
{
|
||||
// Force the current subscription domain to be a direct rule
|
||||
$subsDomain = request()->header('Host');
|
||||
if ($subsDomain) {
|
||||
array_unshift($config['rules'], "DOMAIN,{$subsDomain},DIRECT");
|
||||
}
|
||||
// Force the nodes ip to be a direct rule
|
||||
collect($this->servers)->pluck('host')->map(function($host){
|
||||
$host = trim($host);
|
||||
return filter_var($host, FILTER_VALIDATE_IP) ? [$host] : Helper::getIpByDomainName($host);
|
||||
})->flatten()->unique()->each(function($nodeIP) use ( &$config ) {
|
||||
array_unshift($config['rules'], "IP-CIDR,{$nodeIP}/32,DIRECT,no-resolve");
|
||||
});
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
public static function buildShadowsocks($password, $server)
|
||||
{
|
||||
$array = [];
|
||||
|
||||
Reference in New Issue
Block a user