fix: 修复hiddify无法自动下发hy2节点的问题

This commit is contained in:
xboard 2023-12-03 22:17:33 +08:00
parent 8d4846329e
commit 4a6339c9db
5 changed files with 269 additions and 266 deletions

View File

@ -26,6 +26,7 @@ class ClientController extends Controller
$filterArr = (mb_strlen($request->input('filter')) > 20) ? null : explode("|" ,str_replace(['|','',','], "|" , $request->input('filter')));
$flag = $request->input('flag') ?? $request->header('User-Agent', '');
$flag = strtolower($flag);
$ip = $request->input('ip') ?? $request->ip();
preg_match('/\/v?(\d+(\.\d+){0,2})/', $flag, $matches);
@ -52,7 +53,6 @@ class ClientController extends Controller
if(config('app.debug')){
Log::channel('daily')->info($flag);
}
$flag = strtolower($flag);
$user = $request->user;
// account not expired and is not banned.
$userService = new UserService();
@ -82,7 +82,7 @@ class ClientController extends Controller
if($filterArr){
$rejectFlag = true;
foreach($filterArr as $filter){
if(strpos($server['name'],$filter) !== false) $rejectFlag = false;
if(stripos($server['name'],$filter) !== false) $rejectFlag = false;
}
if($rejectFlag) return true;
}
@ -94,7 +94,7 @@ class ClientController extends Controller
$excludeList = explode("|",str_replace(["",","," ",""],"|",$v));
$rejectFlag = false;
foreach($excludeList as $needle){
if(strpos($region, $needle) !== false){
if(stripos($region, $needle) !== false){
return true;
}
}
@ -131,7 +131,7 @@ class ClientController extends Controller
$classFlags = explode(',', $class->flag);
$isMatch = function() use ($classFlags, $flag){
foreach ($classFlags as $classFlag){
if(strpos($flag, $classFlag) !== false) return true;
if(stripos($flag, $classFlag) !== false) return true;
}
return false;
};

View File

@ -5,7 +5,7 @@ use App\Utils\Helper;
class SingBox
{
public $flag = 'sing-box,Hiddify';
public $flag = 'sing-box,hiddify';
private $servers;
private $user;
@ -17,13 +17,16 @@ class SingBox
public function handle()
{
$appName = config('app_name', 'V2Board');
$appName = config('app_name', 'XBoard');
$config = $this->loadConfig();
$outbounds = $this->buildOutbounds();
$config['outbounds'] = $outbounds;
$user = $this->user;
return json_encode($config);
//return response($config, 200);
return response($config, 200)
->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));
}
protected function loadConfig()

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.