Browse Source

sni for xtls

MHSanaei 1 year ago
parent
commit
9bbcb74db6
3 changed files with 15 additions and 0 deletions
  1. 6 0
      web/assets/js/model/xray.js
  2. 3 0
      web/html/xui/form/tls_settings.html
  3. 6 0
      web/service/sub.go

+ 6 - 0
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);
         }
 

+ 3 - 0
web/html/xui/form/tls_settings.html

@@ -100,6 +100,9 @@
     <a-form-item label='{{ i18n "domainName" }}'>
         <a-input v-model.trim="inbound.stream.xtls.server"></a-input>
     </a-form-item>
+    <a-form-item label="SNI" placeholder="Server Name Indication">
+        <a-input v-model.trim="inbound.stream.xtls.settings.serverName" style="width: 250px"></a-input>
+    </a-form-item>
     <a-form-item label="Alpn">
         <a-checkbox-group v-model="inbound.stream.xtls.alpn" style="width:200px">
             <a-checkbox v-for="key in ALPN_OPTION" :value="key">[[ key ]]</a-checkbox>

+ 6 - 0
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 {