Fix: Handle null content in PlanResource::formatContent method
Some checks failed
Docker Build and Publish / build (push) Has been cancelled

- Fix deprecated warning when passing null to str_replace() function\n- Use null coalescing operator to provide empty string as default value\n- Comply with PHP 8.2+ type requirements
This commit is contained in:
xboard 2025-02-25 19:14:19 +08:00
parent 220d306a54
commit 5a08754735
5 changed files with 10 additions and 3 deletions

View File

@ -27,6 +27,7 @@ class ClientController extends Controller
'vmess' => '[vmess]', 'vmess' => '[vmess]',
'trojan' => '[trojan]', 'trojan' => '[trojan]',
'tuic' => '[tuic]', 'tuic' => '[tuic]',
'socks' => '[socks]',
]; ];
// 支持hy2 的客户端版本列表 // 支持hy2 的客户端版本列表

View File

@ -147,6 +147,9 @@ class UniProxyController extends Controller
'zero_rtt_handshake' => false, 'zero_rtt_handshake' => false,
'heartbeat' => "3s", 'heartbeat' => "3s",
], ],
'socks' => [
'server_port' => (int) $serverPort,
],
default => [] default => []
}; };

View File

@ -52,6 +52,8 @@ class ServerSave extends FormRequest
'reality_settings.public_key' => 'nullable|string', 'reality_settings.public_key' => 'nullable|string',
'reality_settings.private_key' => 'nullable|string', 'reality_settings.private_key' => 'nullable|string',
'reality_settings.short_id' => 'nullable|string', 'reality_settings.short_id' => 'nullable|string',
],
'socks' => [
] ]
]; ];
@ -81,7 +83,7 @@ class ServerSave extends FormRequest
{ {
$type = $this->input('type'); $type = $this->input('type');
$rules = $this->getBaseRules(); $rules = $this->getBaseRules();
foreach (self::PROTOCOL_RULES[$type] ?? [] as $field => $rule) { foreach (self::PROTOCOL_RULES[$type] ?? [] as $field => $rule) {
$rules['protocol_settings.' . $field] = $rule; $rules['protocol_settings.' . $field] = $rule;
} }

View File

@ -80,7 +80,7 @@ class PlanResource extends JsonResource
*/ */
protected function formatContent(): string protected function formatContent(): string
{ {
$content = $this->resource['content']; $content = $this->resource['content'] ?? '';
$replacements = [ $replacements = [
'{{transfer}}' => $this->resource['transfer_enable'], '{{transfer}}' => $this->resource['transfer_enable'],

View File

@ -18,7 +18,7 @@ class Server extends Model
public const TYPE_VMESS = 'vmess'; public const TYPE_VMESS = 'vmess';
public const TYPE_TUIC = 'tuic'; public const TYPE_TUIC = 'tuic';
public const TYPE_SHADOWSOCKS = 'shadowsocks'; public const TYPE_SHADOWSOCKS = 'shadowsocks';
public const TYPE_SOCKS = 'socks';
public const STATUS_OFFLINE = 0; public const STATUS_OFFLINE = 0;
public const STATUS_ONLINE_NO_PUSH = 1; public const STATUS_ONLINE_NO_PUSH = 1;
public const STATUS_ONLINE = 2; public const STATUS_ONLINE = 2;
@ -52,6 +52,7 @@ class Server extends Model
self::TYPE_VMESS, self::TYPE_VMESS,
self::TYPE_TUIC, self::TYPE_TUIC,
self::TYPE_SHADOWSOCKS, self::TYPE_SHADOWSOCKS,
self::TYPE_SOCKS,
]; ];
protected $table = 'v2_server'; protected $table = 'v2_server';