Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/sub
diff options
context:
space:
mode:
authormhsanaei <ho3ein.sanaei@gmail.com>2024-04-01 10:52:10 +0300
committermhsanaei <ho3ein.sanaei@gmail.com>2024-04-01 10:52:10 +0300
commit866f7bd0422be5537b53905cf3b3577d97747025 (patch)
tree5e86648a7f3f23e2778017a1d99ad537a188152b /sub
parent9454af46b70650e2bdf47159b2ab7184e3ebba42 (diff)
[subjson] avoid array for one config
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'sub')
-rw-r--r--sub/subJsonService.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/sub/subJsonService.go b/sub/subJsonService.go
index 70d58ebe..057c1e81 100644
--- a/sub/subJsonService.go
+++ b/sub/subJsonService.go
@@ -127,7 +127,12 @@ func (s *SubJsonService) GetJson(subId string, host string) (string, string, err
}
// Combile outbounds
- finalJson, _ := json.MarshalIndent(configArray, "", " ")
+ var finalJson []byte
+ if len(configArray) == 1 {
+ finalJson, _ = json.MarshalIndent(configArray[0], "", " ")
+ } else {
+ finalJson, _ = json.MarshalIndent(configArray, "", " ")
+ }
header = fmt.Sprintf("upload=%d; download=%d; total=%d; expire=%d", traffic.Up, traffic.Down, traffic.Total, traffic.ExpiryTime/1000)
return string(finalJson), header, nil
@@ -186,6 +191,7 @@ func (s *SubJsonService) getConfig(inbound *model.Inbound, client model.Client,
}
newConfigJson["outbounds"] = newOutbounds
newConfigJson["remarks"] = s.SubService.genRemark(inbound, client.Email, extPrxy["remark"].(string))
+
newConfig, _ := json.MarshalIndent(newConfigJson, "", " ")
newJsonArray = append(newJsonArray, newConfig)
}
@@ -215,6 +221,8 @@ func (s *SubJsonService) streamData(stream string) map[string]interface{} {
streamSettings["tcpSettings"] = s.removeAcceptProxy(streamSettings["tcpSettings"])
case "ws":
streamSettings["wsSettings"] = s.removeAcceptProxy(streamSettings["wsSettings"])
+ case "httpupgrade":
+ streamSettings["httpupgradeSettings"] = s.removeAcceptProxy(streamSettings["httpupgradeSettings"])
}
return streamSettings