From 0bbdf7a5584f44bfa0ce6971e9af7fce1d17f490 Mon Sep 17 00:00:00 2001 From: xboard Date: Fri, 17 Jan 2025 10:21:45 +0800 Subject: [PATCH] fix: correct know issues --- app/Protocols/SingBox.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/Protocols/SingBox.php b/app/Protocols/SingBox.php index a2a2d16..b5fdf01 100644 --- a/app/Protocols/SingBox.php +++ b/app/Protocols/SingBox.php @@ -184,15 +184,21 @@ class SingBox implements ProtocolInterface 'fingerprint' => Helper::getRandFingerprint() ] ]; - if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) { - $tlsConfig['server_name'] = $serverName; - } - if ($protocol_settings['tls'] == 2) { - $tlsConfig['reality'] = [ - 'enabled' => true, - 'public_key' => data_get($protocol_settings, 'reality_settings.public_key'), - 'short_id' => data_get($protocol_settings, 'reality_settings.short_id') - ]; + + switch ($protocol_settings['tls']) { + case 1: + if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) { + $tlsConfig['server_name'] = $serverName; + } + break; + case 2: + $tlsConfig['server_name'] = data_get($protocol_settings, 'reality_settings.server_name'); + $tlsConfig['reality'] = [ + 'enabled' => true, + 'public_key' => data_get($protocol_settings, 'reality_settings.public_key'), + 'short_id' => data_get($protocol_settings, 'reality_settings.short_id') + ]; + break; } $array['tls'] = $tlsConfig;