From ccbd5c6a0dbd645fc1540529db1de03e378d3072 Mon Sep 17 00:00:00 2001 From: Ilya05228 Date: Thu, 28 Aug 2025 16:52:27 +0300 Subject: [PATCH 1/2] fix: SpiderX --- sub/subService.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sub/subService.go b/sub/subService.go index dfb0863e..d831b192 100644 --- a/sub/subService.go +++ b/sub/subService.go @@ -442,7 +442,11 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string { params["pqv"] = pqv } } - params["spx"] = "/" + random.Seq(15) + if spxValue, ok := searchKey(realitySettings, "spiderX"); ok { + if spx, ok := spxValue.(string); ok && len(spx) > 0 { + params["spx"] = spx + } + } } if streamNetwork == "tcp" && len(clients[clientIndex].Flow) > 0 { @@ -637,7 +641,11 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string params["pqv"] = pqv } } - params["spx"] = "/" + random.Seq(15) + if spxValue, ok := searchKey(realitySettings, "spiderX"); ok { + if spx, ok := spxValue.(string); ok && len(spx) > 0 { + params["spx"] = spx + } + } } if streamNetwork == "tcp" && len(clients[clientIndex].Flow) > 0 { From 0763f191c67e23e778a1168fae3923dce62f83be Mon Sep 17 00:00:00 2001 From: Ilya05228 Date: Thu, 28 Aug 2025 20:52:29 +0300 Subject: [PATCH 2/2] fix: sub services --- sub/subJsonService.go | 20 ++++++++++++-------- sub/subService.go | 21 +++++++++++++-------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/sub/subJsonService.go b/sub/subJsonService.go index 680a01c0..e4a58019 100644 --- a/sub/subJsonService.go +++ b/sub/subJsonService.go @@ -87,24 +87,28 @@ func (s *SubJsonService) GetJson(subId string, host string) (string, string, err if clients == nil { continue } - if len(inbound.Listen) > 0 && inbound.Listen[0] == '@' { - listen, port, streamSettings, err := s.SubService.getFallbackMaster(inbound.Listen, inbound.StreamSettings) - if err == nil { - inbound.Listen = listen - inbound.Port = port - inbound.StreamSettings = streamSettings + listenAddress := host + if len(inbound.Listen) > 0 { + if inbound.Listen[0] == '@' { + listen, port, streamSettings, err := s.SubService.getFallbackMaster(inbound.Listen, inbound.StreamSettings) + if err == nil { + listenAddress = listen + inbound.Port = port + inbound.StreamSettings = streamSettings + } + } else { + listenAddress = inbound.Listen } } for _, client := range clients { if client.Enable && client.SubID == subId { clientTraffics = append(clientTraffics, s.SubService.getClientTraffics(inbound.ClientStats, client.Email)) - newConfigs := s.getConfig(inbound, client, host) + newConfigs := s.getConfig(inbound, client, listenAddress) configArray = append(configArray, newConfigs...) } } } - if len(configArray) == 0 { return "", "", nil } diff --git a/sub/subService.go b/sub/subService.go index d831b192..dedff004 100644 --- a/sub/subService.go +++ b/sub/subService.go @@ -1,5 +1,7 @@ package sub +// TODO: We need to create a service for link generation and remove link generation from the frontend + import ( "encoding/base64" "fmt" @@ -33,9 +35,7 @@ func NewSubService(showInfo bool, remarkModel string) *SubService { remarkModel: remarkModel, } } - func (s *SubService) GetSubs(subId string, host string) ([]string, string, error) { - s.address = host var result []string var header string var traffic xray.ClientTraffic @@ -61,12 +61,17 @@ func (s *SubService) GetSubs(subId string, host string) ([]string, string, error if clients == nil { continue } - if len(inbound.Listen) > 0 && inbound.Listen[0] == '@' { - listen, port, streamSettings, err := s.getFallbackMaster(inbound.Listen, inbound.StreamSettings) - if err == nil { - inbound.Listen = listen - inbound.Port = port - inbound.StreamSettings = streamSettings + s.address = host + if len(inbound.Listen) > 0 { + if inbound.Listen[0] == '@' { + listen, port, streamSettings, err := s.getFallbackMaster(inbound.Listen, inbound.StreamSettings) + if err == nil { + s.address = listen + inbound.Port = port + inbound.StreamSettings = streamSettings + } + } else { + s.address = inbound.Listen } } for _, client := range clients {