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
diff options
context:
space:
mode:
authorAlireza Ahmadi <alireza7@gmail.com>2023-12-08 22:31:17 +0300
committerAlireza Ahmadi <alireza7@gmail.com>2023-12-08 22:31:17 +0300
commitc980a06969c9595f0b0b7d5db301f2413506eb6f (patch)
treec5e3cca1eeda78e613134034e02ea78b82a0d52e /sub/subService.go
parent35feef650f793ffbec2af51a18fd25d8b0beefb1 (diff)
customizable remark #1300
Diffstat (limited to 'sub/subService.go')
-rw-r--r--sub/subService.go40
1 files changed, 29 insertions, 11 deletions
diff --git a/sub/subService.go b/sub/subService.go
index a1cbbb0f..251ef2e8 100644
--- a/sub/subService.go
+++ b/sub/subService.go
@@ -19,6 +19,7 @@ import (
type SubService struct {
address string
showInfo bool
+ remarkModel string
inboundService service.InboundService
settingService service.SettingService
}
@@ -34,6 +35,10 @@ func (s *SubService) GetSubs(subId string, host string, showInfo bool) ([]string
if err != nil {
return nil, nil, err
}
+ s.remarkModel, err = s.settingService.GetRemarkModel()
+ if err != nil {
+ s.remarkModel = "-ieo"
+ }
for _, inbound := range inbounds {
clients, err := s.inboundService.GetClients(inbound)
if err != nil {
@@ -857,17 +862,30 @@ func (s *SubService) genShadowsocksLink(inbound *model.Inbound, email string) st
}
func (s *SubService) genRemark(inbound *model.Inbound, email string, extra string) string {
- var remark []string
+ separationChar := string(s.remarkModel[0])
+ orderChars := s.remarkModel[1:]
+ orders := map[byte]string{
+ 'i': "",
+ 'e': "",
+ 'o': "",
+ }
if len(email) > 0 {
- if len(inbound.Remark) > 0 {
- remark = append(remark, inbound.Remark)
- }
- remark = append(remark, email)
- if len(extra) > 0 {
- remark = append(remark, extra)
+ orders['e'] = email
+ }
+ if len(inbound.Remark) > 0 {
+ orders['i'] = inbound.Remark
+ }
+ if len(extra) > 0 {
+ orders['e'] = extra
+ }
+
+ var remark []string
+ for i := 0; i < len(orderChars); i++ {
+ char := orderChars[i]
+ order, exists := orders[char]
+ if exists && order != "" {
+ remark = append(remark, order)
}
- } else {
- return inbound.Remark
}
if s.showInfo {
@@ -884,7 +902,7 @@ func (s *SubService) genRemark(inbound *model.Inbound, email string, extra strin
// Get remained days
if statsExist {
if !stats.Enable {
- return fmt.Sprintf("⛔️N/A-%s", strings.Join(remark, "-"))
+ return fmt.Sprintf("⛔️N/A%s%s", separationChar, strings.Join(remark, separationChar))
}
if vol := stats.Total - (stats.Up + stats.Down); vol > 0 {
remark = append(remark, fmt.Sprintf("%s%s", common.FormatTraffic(vol), "📊"))
@@ -898,7 +916,7 @@ func (s *SubService) genRemark(inbound *model.Inbound, email string, extra strin
}
}
}
- return strings.Join(remark, " : ")
+ return strings.Join(remark, separationChar)
}
func searchKey(data interface{}, key string) (interface{}, bool) {