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

View File

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

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.