From 9bbcb74db6a935d19cf5c79c0bade33bdb253bfb Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sun, 7 May 2023 19:59:06 +0330 Subject: [PATCH] sni for xtls --- web/assets/js/model/xray.js | 6 ++++++ web/html/xui/form/tls_settings.html | 3 +++ web/service/sub.go | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index 37717c9e..2d4ba84c 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -1355,6 +1355,9 @@ class Inbound extends XrayCommonClass { if (!ObjectUtil.isEmpty(this.stream.xtls.server)) { address = this.stream.xtls.server; } + if (this.stream.xtls.settings.serverName !== ''){ + params.set("sni", this.stream.xtls.settings.serverName); + } params.set("flow", this.settings.vlesses[clientIndex].flow); } @@ -1485,6 +1488,9 @@ class Inbound extends XrayCommonClass { if (!ObjectUtil.isEmpty(this.stream.xtls.server)) { address = this.stream.xtls.server; } + if (this.stream.xtls.settings.serverName !== ''){ + params.set("sni", this.stream.xtls.settings.serverName); + } params.set("flow", this.settings.trojans[clientIndex].flow); } diff --git a/web/html/xui/form/tls_settings.html b/web/html/xui/form/tls_settings.html index e6e0bece..5e02f985 100644 --- a/web/html/xui/form/tls_settings.html +++ b/web/html/xui/form/tls_settings.html @@ -100,6 +100,9 @@ + + + [[ key ]] diff --git a/web/service/sub.go b/web/service/sub.go index 3f8b7685..9a86c3eb 100644 --- a/web/service/sub.go +++ b/web/service/sub.go @@ -360,6 +360,9 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string { params["allowInsecure"] = "1" } } + if sniValue, ok := searchKey(xtlsSettings, "serverName"); ok { + params["sni"], _ = sniValue.(string) + } } if streamNetwork == "tcp" && len(clients[clientIndex].Flow) > 0 { @@ -538,6 +541,9 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string params["allowInsecure"] = "1" } } + if sniValue, ok := searchKey(xtlsSettings, "serverName"); ok { + params["sni"], _ = sniValue.(string) + } } if streamNetwork == "tcp" && len(clients[clientIndex].Flow) > 0 {