From 3af55cc5b499994924be25fa54a851de2ed05d90 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Mon, 11 Mar 2024 13:34:15 +0330 Subject: [PATCH] [sub] random reality params Co-Authored-By: Alireza Ahmadi --- sub/subService.go | 21 +++++++------------ web/html/xui/form/outbound.html | 4 ++-- .../xui/form/stream/stream_httpupgrade.html | 2 +- web/html/xui/form/stream/stream_settings.html | 6 +++--- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/sub/subService.go b/sub/subService.go index 97473159..0ed1d454 100644 --- a/sub/subService.go +++ b/sub/subService.go @@ -11,6 +11,7 @@ import ( "x-ui/database/model" "x-ui/logger" "x-ui/util/common" + "x-ui/util/random" "x-ui/web/service" "x-ui/xray" @@ -402,25 +403,21 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string { if realitySetting != nil { if sniValue, ok := searchKey(realitySetting, "serverNames"); ok { sNames, _ := sniValue.([]interface{}) - params["sni"], _ = sNames[0].(string) + params["sni"] = sNames[random.Num(len(sNames))].(string) } if pbkValue, ok := searchKey(realitySettings, "publicKey"); ok { params["pbk"], _ = pbkValue.(string) } if sidValue, ok := searchKey(realitySetting, "shortIds"); ok { shortIds, _ := sidValue.([]interface{}) - params["sid"], _ = shortIds[0].(string) + params["sid"] = shortIds[random.Num(len(shortIds))].(string) } if fpValue, ok := searchKey(realitySettings, "fingerprint"); ok { if fp, ok := fpValue.(string); ok && len(fp) > 0 { params["fp"] = fp } } - if spxValue, ok := searchKey(realitySettings, "spiderX"); ok { - if spx, ok := spxValue.(string); ok && len(spx) > 0 { - params["spx"] = spx - } - } + params["spx"] = "/" + random.Seq(15) } if streamNetwork == "tcp" && len(clients[clientIndex].Flow) > 0 { @@ -619,25 +616,21 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string if realitySetting != nil { if sniValue, ok := searchKey(realitySetting, "serverNames"); ok { sNames, _ := sniValue.([]interface{}) - params["sni"], _ = sNames[0].(string) + params["sni"] = sNames[random.Num(len(sNames))].(string) } if pbkValue, ok := searchKey(realitySettings, "publicKey"); ok { params["pbk"], _ = pbkValue.(string) } if sidValue, ok := searchKey(realitySetting, "shortIds"); ok { shortIds, _ := sidValue.([]interface{}) - params["sid"], _ = shortIds[0].(string) + params["sid"] = shortIds[random.Num(len(shortIds))].(string) } if fpValue, ok := searchKey(realitySettings, "fingerprint"); ok { if fp, ok := fpValue.(string); ok && len(fp) > 0 { params["fp"] = fp } } - if spxValue, ok := searchKey(realitySettings, "spiderX"); ok { - if spx, ok := spxValue.(string); ok && len(spx) > 0 { - params["spx"] = spx - } - } + params["spx"] = "/" + random.Seq(15) } if streamNetwork == "tcp" && len(clients[clientIndex].Flow) > 0 { diff --git a/web/html/xui/form/outbound.html b/web/html/xui/form/outbound.html index 2f2a5215..e3d6a560 100644 --- a/web/html/xui/form/outbound.html +++ b/web/html/xui/form/outbound.html @@ -219,11 +219,11 @@ :dropdown-class-name="themeSwitcher.currentTheme"> TCP mKCP - WS + WebSocket H2 QUIC gRPC - HttpUpgrade + HTTPUpgrade