From e2a3a1e72d53a3bc0d62f4625aeb3a56f3a7f620 Mon Sep 17 00:00:00 2001 From: Beta Soft Date: Fri, 24 Apr 2020 11:42:24 +0800 Subject: [PATCH] subscription: Improved TLS support Signed-off-by: Beta Soft --- app/Http/Controllers/Client/ClientController.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Client/ClientController.php b/app/Http/Controllers/Client/ClientController.php index 2c70a021..98c7236a 100644 --- a/app/Http/Controllers/Client/ClientController.php +++ b/app/Http/Controllers/Client/ClientController.php @@ -53,6 +53,17 @@ class ClientController extends Controller $uri = ''; foreach ($server as $item) { $uri .= "vmess=" . $item->host . ":" . $item->port . ", method=none, password=" . $user->v2ray_uuid . ", fast-open=false, udp-relay=false, tag=" . $item->name; + if ($item->tls) { + $tlsSettings = json_decode($item->tlsSettings); + $uri .= ', obfs=over-tls'; + if (isset($tlsSettings->allowInsecure)) { + // Default: tls-verification=true + $uri .= ', tls-verification=' . ($tlsSettings->allowInsecure ? "false" : "true"); + } + if (isset($tlsSettings->serverName)) { + $uri .= ', obfs-host=' . $tlsSettings->serverName; + } + } if ($item->network == 'ws') { $uri .= ', obfs=' . ($item->tls ? 'wss' : 'ws'); if ($item->networkSettings) { @@ -106,7 +117,7 @@ class ClientController extends Controller $tlsSettings = json_decode($item->tlsSettings); $proxies .= ', tls=' . ($item->tls ? "true" : "false"); if (isset($tlsSettings->allowInsecure)) { - $proxies .= ', skip-cert-verify=true'; + $proxies .= ', skip-cert-verify=' . ($tlsSettings->allowInsecure ? "true" : "false"); } } if ($item->network == 'ws') { @@ -163,8 +174,9 @@ class ClientController extends Controller $array['alterId'] = $user->v2ray_alter_id; $array['cipher'] = 'auto'; if ($item->tls) { + $tlsSettings = json_decode($item->tlsSettings); $array['tls'] = true; - $array['skip-cert-verify'] = true; + if (isset($tlsSettings->allowInsecure)) $array['skip-cert-verify'] = ($tlsSettings->allowInsecure ? true : false ); } if ($item->network == 'ws') { $array['network'] = $item->network;