fix: resolve PHPStan static analysis warnings

This commit is contained in:
xboard
2025-04-14 02:12:42 +08:00
parent 3d254c02c1
commit 2d3e4b4a95
84 changed files with 2330 additions and 1190 deletions

View File

@@ -5,7 +5,7 @@ namespace App\Protocols;
use App\Contracts\ProtocolInterface;
use App\Utils\Helper;
use Illuminate\Support\Arr;
class General implements ProtocolInterface
{
public $flags = ['general', 'v2rayn', 'v2rayng', 'passwall', 'ssrplus', 'sagernet'];
@@ -45,6 +45,9 @@ class General implements ProtocolInterface
if ($item['type'] === 'hysteria') {
$uri .= self::buildHysteria($user['uuid'], $item);
}
if ($item['type'] === 'socks') {
$uri .= self::buildSocks($user['uuid'], $item);
}
}
return base64_encode($uri);
}
@@ -87,8 +90,11 @@ class General implements ProtocolInterface
case 'tcp':
if (data_get($protocol_settings, 'network_settings.header.type', 'none') !== 'none') {
$config['type'] = data_get($protocol_settings, 'network_settings.header.type', 'http');
$config['path'] = \Arr::random(data_get($protocol_settings, 'network_settings.header.request.path', ['/']));
$config['host'] = data_get($protocol_settings, 'network_settings.headers.Host') ? \Arr::random(data_get($protocol_settings, 'network_settings.headers.Host'), ['/']) : null;
$config['path'] = Arr::random(data_get($protocol_settings, 'network_settings.header.request.path', ['/']));
$config['host'] =
data_get($protocol_settings, 'network_settings.headers.Host')
? Arr::random(data_get($protocol_settings, 'network_settings.headers.Host', ['/']), )
: null;
}
break;
case 'ws':
@@ -249,4 +255,11 @@ class General implements ProtocolInterface
return $uri;
}
public static function buildSocks($password, $server)
{
$name = rawurlencode($server['name']);
$credentials = base64_encode("{$password}:{$password}");
return "socks://{$credentials}@{$server['host']}:{$server['port']}#{$name}\r\n";
}
}