From af747c61cc9c50b68ae3d53d4217bea6651c6238 Mon Sep 17 00:00:00 2001 From: xboard Date: Sat, 23 Aug 2025 11:19:37 +0800 Subject: [PATCH] refactor(singbox): use data_get for array access --- app/Protocols/SingBox.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Protocols/SingBox.php b/app/Protocols/SingBox.php index c2d2ccd..533726c 100644 --- a/app/Protocols/SingBox.php +++ b/app/Protocols/SingBox.php @@ -351,7 +351,7 @@ class SingBox extends AbstractProtocol 'tag' => $server['name'], 'tls' => [ 'enabled' => true, - 'insecure' => (bool) $protocol_settings['tls']['allow_insecure'], + 'insecure' => (bool) data_get($protocol_settings, 'tls.allow_insecure', false), ] ]; // 支持 1.11.0 版本及以上 `server_ports` 和 `hop_interval` 配置 @@ -368,22 +368,22 @@ class SingBox extends AbstractProtocol $baseConfig['tls']['server_name'] = $serverName; } $speedConfig = [ - 'up_mbps' => $protocol_settings['bandwidth']['up'], - 'down_mbps' => $protocol_settings['bandwidth']['down'], + 'up_mbps' => data_get($protocol_settings, 'bandwidth.up'), + 'down_mbps' => data_get($protocol_settings, 'bandwidth.down'), ]; $versionConfig = match (data_get($protocol_settings, 'version', 1)) { 2 => [ 'type' => 'hysteria2', 'password' => $password, - 'obfs' => $protocol_settings['obfs']['open'] ? [ - 'type' => $protocol_settings['obfs']['type'], - 'password' => $protocol_settings['obfs']['password'] + 'obfs' => data_get($protocol_settings, 'obfs.open') ? [ + 'type' => data_get($protocol_settings, 'obfs.type'), + 'password' => data_get($protocol_settings, 'obfs.password') ] : null, ], default => [ 'type' => 'hysteria', 'auth_str' => $password, - 'obfs' => $protocol_settings['obfs']['password'], + 'obfs' => data_get($protocol_settings, 'obfs.password'), 'disable_mtu_discovery' => true, ] };