feat: add Vless Encryption support

This commit is contained in:
xboard
2026-03-30 17:03:37 +08:00
parent 0cd20d12dd
commit 5f1afe4bdc
6 changed files with 23 additions and 2 deletions
+4
View File
@@ -71,6 +71,10 @@ class ServerSave extends FormRequest
'network' => 'required|string', 'network' => 'required|string',
'network_settings' => 'nullable|array', 'network_settings' => 'nullable|array',
'flow' => 'nullable|string', '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.server_name' => 'nullable|string',
'tls_settings.allow_insecure' => 'nullable|boolean', 'tls_settings.allow_insecure' => 'nullable|boolean',
'reality_settings.allow_insecure' => 'nullable|boolean', 'reality_settings.allow_insecure' => 'nullable|boolean',
+9
View File
@@ -203,6 +203,15 @@ class Server extends Model
'tls' => ['type' => 'integer', 'default' => 0], 'tls' => ['type' => 'integer', 'default' => 0],
'tls_settings' => ['type' => 'array', 'default' => null], 'tls_settings' => ['type' => 'array', 'default' => null],
'flow' => ['type' => 'string', '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' => ['type' => 'string', 'default' => null],
'network_settings' => ['type' => 'array', 'default' => null], 'network_settings' => ['type' => 'array', 'default' => null],
...self::REALITY_CONFIGURATION, ...self::REALITY_CONFIGURATION,
+4
View File
@@ -332,6 +332,10 @@ class ClashMeta extends AbstractProtocol
'cipher' => 'auto', 'cipher' => 'auto',
'udp' => true, 'udp' => true,
'flow' => data_get($protocol_settings, 'flow'), '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 'tls' => false
]; ];
+4 -1
View File
@@ -151,7 +151,10 @@ class General extends AbstractProtocol
$config = [ $config = [
'mode' => 'multi', //grpc传输模式 'mode' => 'multi', //grpc传输模式
'security' => '', //传输层安全 tls/reality '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'), //传输协议 'type' => data_get($server, 'protocol_settings.network'), //传输协议
'flow' => data_get($protocol_settings, 'flow'), 'flow' => data_get($protocol_settings, 'flow'),
]; ];
+1
View File
@@ -183,6 +183,7 @@ class ServerService
...$baseConfig, ...$baseConfig,
'tls' => (int) $protocolSettings['tls'], 'tls' => (int) $protocolSettings['tls'],
'flow' => $protocolSettings['flow'], 'flow' => $protocolSettings['flow'],
'decryption' => data_get($protocolSettings, 'encryption.decryption'),
'tls_settings' => match ((int) $protocolSettings['tls']) { 'tls_settings' => match ((int) $protocolSettings['tls']) {
2 => $protocolSettings['reality_settings'], 2 => $protocolSettings['reality_settings'],
default => $protocolSettings['tls_settings'], default => $protocolSettings['tls_settings'],