mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-23 19:37:35 +08:00
feat: Singbox、clash订阅增加绕过服务器地址规则
1、优化订阅下发代码 2、singbox、clash、meta订阅下发增加绕过服务器地址规则,防止重复代理
This commit is contained in:
@@ -21,12 +21,13 @@ class SingBox
|
||||
$appName = admin_setting('app_name', 'XBoard');
|
||||
$this->config = $this->loadConfig();
|
||||
$this->buildOutbounds();
|
||||
$this->buildRule();
|
||||
$user = $this->user;
|
||||
|
||||
return response($this->config, 200)
|
||||
return response()
|
||||
->json($this->config)
|
||||
->header('subscription-userinfo', "upload={$user['u']}; download={$user['d']}; total={$user['transfer_enable']}; expire={$user['expired_at']}")
|
||||
->header('profile-update-interval', '24')
|
||||
->header('content-disposition', 'attachment;filename*=UTF-8\'\'' . rawurlencode($appName));
|
||||
->header('profile-update-interval', '24');
|
||||
}
|
||||
|
||||
protected function loadConfig()
|
||||
@@ -75,6 +76,21 @@ class SingBox
|
||||
return $outbounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build rule
|
||||
*/
|
||||
protected function buildRule(){
|
||||
$rules = $this->config['route']['rules'];
|
||||
// Force the nodes ip to be a direct rule
|
||||
array_unshift($rules, [
|
||||
'ip_cidr' => collect($this->servers)->pluck('host')->map(function($host){
|
||||
return filter_var($host, FILTER_VALIDATE_IP) ? [$host] : Helper::getIpByDomainName($host);
|
||||
})->flatten()->unique()->values(),
|
||||
'outbound' => 'direct',
|
||||
]);
|
||||
$this->config['route']['rules'] = $rules;
|
||||
}
|
||||
|
||||
protected function buildShadowsocks($password, $server)
|
||||
{
|
||||
$array = [];
|
||||
|
||||
Reference in New Issue
Block a user