Skip to content

Commit

Permalink
[subjson] avoid array for one config
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza0 committed Mar 28, 2024
1 parent de6c768 commit a090c6d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sub/subJsonService.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a090c6d

Please sign in to comment.