diff --git a/app/Http/Requests/Admin/ServerSave.php b/app/Http/Requests/Admin/ServerSave.php index 1038350..bd1f6b2 100644 --- a/app/Http/Requests/Admin/ServerSave.php +++ b/app/Http/Requests/Admin/ServerSave.php @@ -71,6 +71,10 @@ class ServerSave extends FormRequest 'network' => 'required|string', 'network_settings' => 'nullable|array', 'flow' => 'nullable|string', + 'encryption' => 'nullable|array', + 'encryption.enabled' => 'nullable|boolean', + 'encryption.encryption' => 'nullable|string', + 'encryption.decryption' => 'nullable|string', 'tls_settings.server_name' => 'nullable|string', 'tls_settings.allow_insecure' => 'nullable|boolean', 'reality_settings.allow_insecure' => 'nullable|boolean', diff --git a/app/Models/Server.php b/app/Models/Server.php index e04a236..19e2b5e 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -203,6 +203,15 @@ class Server extends Model 'tls' => ['type' => 'integer', 'default' => 0], 'tls_settings' => ['type' => 'array', 'default' => null], 'flow' => ['type' => 'string', 'default' => null], + 'encryption' => [ + 'type' => 'object', + 'default' => null, + 'fields' => [ + 'enabled' => ['type' => 'boolean', 'default' => false], + 'encryption' => ['type' => 'string', 'default' => null], // 客户端公钥 + 'decryption' => ['type' => 'string', 'default' => null], // 服务端私钥 + ] + ], 'network' => ['type' => 'string', 'default' => null], 'network_settings' => ['type' => 'array', 'default' => null], ...self::REALITY_CONFIGURATION, diff --git a/app/Protocols/ClashMeta.php b/app/Protocols/ClashMeta.php index 65d0e2e..feda7d0 100644 --- a/app/Protocols/ClashMeta.php +++ b/app/Protocols/ClashMeta.php @@ -332,6 +332,10 @@ class ClashMeta extends AbstractProtocol 'cipher' => 'auto', 'udp' => true, 'flow' => data_get($protocol_settings, 'flow'), + 'encryption' => match (data_get($protocol_settings, 'encryption.enabled')) { + true => data_get($protocol_settings, 'encryption.encryption', 'none'), + default => 'none' + }, 'tls' => false ]; diff --git a/app/Protocols/General.php b/app/Protocols/General.php index fc635f0..5071027 100644 --- a/app/Protocols/General.php +++ b/app/Protocols/General.php @@ -151,7 +151,10 @@ class General extends AbstractProtocol $config = [ 'mode' => 'multi', //grpc传输模式 'security' => '', //传输层安全 tls/reality - 'encryption' => 'none', //加密方式 + 'encryption' => match (data_get($protocol_settings, 'encryption.enabled')) { + true => data_get($protocol_settings, 'encryption.encryption', 'none'), + default => 'none' + }, 'type' => data_get($server, 'protocol_settings.network'), //传输协议 'flow' => data_get($protocol_settings, 'flow'), ]; diff --git a/app/Services/ServerService.php b/app/Services/ServerService.php index 6a08896..00491ca 100644 --- a/app/Services/ServerService.php +++ b/app/Services/ServerService.php @@ -183,6 +183,7 @@ class ServerService ...$baseConfig, 'tls' => (int) $protocolSettings['tls'], 'flow' => $protocolSettings['flow'], + 'decryption' => data_get($protocolSettings, 'encryption.decryption'), 'tls_settings' => match ((int) $protocolSettings['tls']) { 2 => $protocolSettings['reality_settings'], default => $protocolSettings['tls_settings'], diff --git a/public/assets/admin b/public/assets/admin index 9b2d136..2603902 160000 --- a/public/assets/admin +++ b/public/assets/admin @@ -1 +1 @@ -Subproject commit 9b2d136d811d60fa1a363ea2057e5c15f01a7140 +Subproject commit 260390202f7787b25e910013bc495f1cab3befcb