mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-03 18:40:52 +08:00
Revert "fix: resolve PHPStan static analysis warnings"
This reverts commit 2d3e4b4a95.
This commit is contained in:
@@ -13,11 +13,7 @@ class ClashMeta implements ProtocolInterface
|
||||
private $servers;
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @param mixed $user 用户实例
|
||||
* @param array $servers 服务器列表
|
||||
*/
|
||||
public function __construct($user, $servers)
|
||||
public function __construct($user, $servers, array $options = null)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->servers = $servers;
|
||||
@@ -82,18 +78,6 @@ class ClashMeta implements ProtocolInterface
|
||||
array_push($proxy, self::buildTuic($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
}
|
||||
if ($item['type'] === 'socks') {
|
||||
array_push($proxy, self::buildSocks5($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
}
|
||||
if ($item['type'] === 'http') {
|
||||
array_push($proxy, self::buildHttp($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
}
|
||||
if ($item['type'] === 'mieru') {
|
||||
array_push($proxy, self::buildMieru($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
}
|
||||
}
|
||||
|
||||
$config['proxies'] = array_merge($config['proxies'] ? $config['proxies'] : [], $proxy);
|
||||
@@ -192,7 +176,7 @@ class ClashMeta implements ProtocolInterface
|
||||
if (data_get($protocol_settings, 'network_settings.header.type', 'none') !== 'none') {
|
||||
$array['http-opts'] = [
|
||||
'headers' => data_get($protocol_settings, 'network_settings.header.request.headers'),
|
||||
'path' => \Illuminate\Support\Arr::random(data_get($protocol_settings, 'network_settings.header.request.path', ['/']))
|
||||
'path' => \Arr::random(data_get($protocol_settings, 'network_settings.header.request.path', ['/']))
|
||||
];
|
||||
}
|
||||
break;
|
||||
@@ -385,78 +369,9 @@ class ClashMeta implements ProtocolInterface
|
||||
return $array;
|
||||
}
|
||||
|
||||
public static function buildMieru($password, $server)
|
||||
{
|
||||
$protocol_settings = data_get($server, 'protocol_settings', []);
|
||||
$array = [
|
||||
'name' => $server['name'],
|
||||
'type' => 'mieru',
|
||||
'server' => $server['host'],
|
||||
'port' => $server['port'],
|
||||
'username' => $password,
|
||||
'password' => $password,
|
||||
'transport' => strtoupper(data_get($protocol_settings, 'transport', 'TCP')),
|
||||
'multiplexing' => data_get($protocol_settings, 'multiplexing', 'MULTIPLEXING_LOW')
|
||||
];
|
||||
|
||||
// 如果配置了端口范围
|
||||
if (isset($server['ports'])) {
|
||||
$array['port-range'] = $server['ports'];
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
public static function buildSocks5($password, $server)
|
||||
{
|
||||
$protocol_settings = $server['protocol_settings'];
|
||||
$array = [];
|
||||
$array['name'] = $server['name'];
|
||||
$array['type'] = 'socks5';
|
||||
$array['server'] = $server['host'];
|
||||
$array['port'] = $server['port'];
|
||||
$array['udp'] = true;
|
||||
|
||||
$array['username'] = $password;
|
||||
$array['password'] = $password;
|
||||
|
||||
// TLS 配置
|
||||
if (data_get($protocol_settings, 'tls')) {
|
||||
$array['tls'] = true;
|
||||
$array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'tls_settings.allow_insecure', false);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
public static function buildHttp($password, $server)
|
||||
{
|
||||
$protocol_settings = $server['protocol_settings'];
|
||||
$array = [];
|
||||
$array['name'] = $server['name'];
|
||||
$array['type'] = 'http';
|
||||
$array['server'] = $server['host'];
|
||||
$array['port'] = $server['port'];
|
||||
|
||||
$array['username'] = $password;
|
||||
$array['password'] = $password;
|
||||
|
||||
// TLS 配置
|
||||
if (data_get($protocol_settings, 'tls')) {
|
||||
$array['tls'] = true;
|
||||
$array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'tls_settings.allow_insecure', false);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
private function isMatch($exp, $str)
|
||||
{
|
||||
try {
|
||||
return preg_match($exp, $str) === 1;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
return @preg_match($exp, $str);
|
||||
}
|
||||
|
||||
private function isRegex($exp)
|
||||
@@ -464,10 +379,6 @@ class ClashMeta implements ProtocolInterface
|
||||
if (empty($exp)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return preg_match($exp, '') !== false;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
return @preg_match($exp, '') !== false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user