mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-12 21:20:07 +00:00
fix: sub services
This commit is contained in:
parent
ccbd5c6a0d
commit
0763f191c6
2 changed files with 25 additions and 16 deletions
|
@ -87,24 +87,28 @@ func (s *SubJsonService) GetJson(subId string, host string) (string, string, err
|
||||||
if clients == nil {
|
if clients == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(inbound.Listen) > 0 && inbound.Listen[0] == '@' {
|
listenAddress := host
|
||||||
listen, port, streamSettings, err := s.SubService.getFallbackMaster(inbound.Listen, inbound.StreamSettings)
|
if len(inbound.Listen) > 0 {
|
||||||
if err == nil {
|
if inbound.Listen[0] == '@' {
|
||||||
inbound.Listen = listen
|
listen, port, streamSettings, err := s.SubService.getFallbackMaster(inbound.Listen, inbound.StreamSettings)
|
||||||
inbound.Port = port
|
if err == nil {
|
||||||
inbound.StreamSettings = streamSettings
|
listenAddress = listen
|
||||||
|
inbound.Port = port
|
||||||
|
inbound.StreamSettings = streamSettings
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
listenAddress = inbound.Listen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, client := range clients {
|
for _, client := range clients {
|
||||||
if client.Enable && client.SubID == subId {
|
if client.Enable && client.SubID == subId {
|
||||||
clientTraffics = append(clientTraffics, s.SubService.getClientTraffics(inbound.ClientStats, client.Email))
|
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...)
|
configArray = append(configArray, newConfigs...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(configArray) == 0 {
|
if len(configArray) == 0 {
|
||||||
return "", "", nil
|
return "", "", nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package sub
|
package sub
|
||||||
|
|
||||||
|
// TODO: We need to create a service for link generation and remove link generation from the frontend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -33,9 +35,7 @@ func NewSubService(showInfo bool, remarkModel string) *SubService {
|
||||||
remarkModel: remarkModel,
|
remarkModel: remarkModel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SubService) GetSubs(subId string, host string) ([]string, string, error) {
|
func (s *SubService) GetSubs(subId string, host string) ([]string, string, error) {
|
||||||
s.address = host
|
|
||||||
var result []string
|
var result []string
|
||||||
var header string
|
var header string
|
||||||
var traffic xray.ClientTraffic
|
var traffic xray.ClientTraffic
|
||||||
|
@ -61,12 +61,17 @@ func (s *SubService) GetSubs(subId string, host string) ([]string, string, error
|
||||||
if clients == nil {
|
if clients == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(inbound.Listen) > 0 && inbound.Listen[0] == '@' {
|
s.address = host
|
||||||
listen, port, streamSettings, err := s.getFallbackMaster(inbound.Listen, inbound.StreamSettings)
|
if len(inbound.Listen) > 0 {
|
||||||
if err == nil {
|
if inbound.Listen[0] == '@' {
|
||||||
inbound.Listen = listen
|
listen, port, streamSettings, err := s.getFallbackMaster(inbound.Listen, inbound.StreamSettings)
|
||||||
inbound.Port = port
|
if err == nil {
|
||||||
inbound.StreamSettings = streamSettings
|
s.address = listen
|
||||||
|
inbound.Port = port
|
||||||
|
inbound.StreamSettings = streamSettings
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
s.address = inbound.Listen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, client := range clients {
|
for _, client := range clients {
|
||||||
|
|
Loading…
Reference in a new issue