no message
This commit is contained in:
parent
fa5e467d80
commit
2bb9915ada
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Services\Subscribe;
|
namespace App\Services\Subscribe;
|
||||||
|
|
||||||
use App\Services\Subscribe;
|
use App\Services\Subscribe;
|
||||||
|
use App\Services\TomTool\Nice as TomNice;
|
||||||
use App\Utils\Tools;
|
use App\Utils\Tools;
|
||||||
use function array_merge;
|
use function array_merge;
|
||||||
use function json_decode;
|
use function json_decode;
|
||||||
@ -95,12 +96,12 @@ final class Clash extends Base
|
|||||||
$v2_port = $node_custom_config['offset_port_user'] ??
|
$v2_port = $node_custom_config['offset_port_user'] ??
|
||||||
($node_custom_config['offset_port_node'] ?? 443);
|
($node_custom_config['offset_port_node'] ?? 443);
|
||||||
$network = $node_custom_config['network'] ?? 'tcp';
|
$network = $node_custom_config['network'] ?? 'tcp';
|
||||||
$udp = $node_custom_config['udp'] ?? true;
|
$udp = $node_custom_config['udp'] ?? false;
|
||||||
$tls = $node_custom_config['tls'] ?? true;
|
$tls = $node_custom_config['tls'] ?? false;
|
||||||
$browser = $node_custom_config['browser'] ?? 'chrome';
|
$browser = $node_custom_config['browser'] ?? 'chrome';
|
||||||
$servername = $node_custom_config['servername'] ?? '';
|
$servername = $node_custom_config['servername'] ?? '';
|
||||||
$flow = $node_custom_config['flow'] ?? '';
|
$flow = $node_custom_config['flow'] ?? '';
|
||||||
|
|
||||||
$node = [
|
$node = [
|
||||||
'name' => $node_raw->name,
|
'name' => $node_raw->name,
|
||||||
'type' => 'vless',
|
'type' => 'vless',
|
||||||
@ -108,8 +109,8 @@ final class Clash extends Base
|
|||||||
'port' => (int) $v2_port,
|
'port' => (int) $v2_port,
|
||||||
'network' => $network,
|
'network' => $network,
|
||||||
'uuid' => $user->uuid,
|
'uuid' => $user->uuid,
|
||||||
'udp' => (bool) $udp,
|
'udp' => (bool) TomNice::ensureBool($udp),
|
||||||
'tls' => (bool) $tls,
|
'tls' => (bool) TomNice::ensureBool($tls),
|
||||||
'servername' => $servername,
|
'servername' => $servername,
|
||||||
'flow' => $flow,
|
'flow' => $flow,
|
||||||
'client-fingerprint' => $browser
|
'client-fingerprint' => $browser
|
||||||
|
|||||||
30
src/Services/TomTool/Nice.php
Executable file
30
src/Services/TomTool/Nice.php
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Services\TomTool;
|
||||||
|
|
||||||
|
class Nice
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 确保返回必然的布尔值
|
||||||
|
*
|
||||||
|
* @param mixed $xValue 传入的原始数据 (x前缀代表未知类型)
|
||||||
|
* @param bool $bDefault 默认值
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function ensureBool(mixed $xValue, bool $bDefault = false): bool
|
||||||
|
{
|
||||||
|
// 如果为 null 直接返回默认值,避免 filter_var 的空字符串陷阱
|
||||||
|
if (is_null($xValue)) {
|
||||||
|
return $bDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 严谨校验:确保字符串 "false", "no", "0" 都能正确识别
|
||||||
|
return filter_var($xValue, FILTER_VALIDATE_BOOLEAN, [
|
||||||
|
'flags' => FILTER_NULL_ON_FAILURE
|
||||||
|
]) ?? $bDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user