diff --git a/sub/subService.go b/sub/subService.go index 43457a2d..7c2371a1 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 { @@ -793,17 +798,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) + 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) } - remark = append(remark, email) - if len(extra) > 0 { - remark = append(remark, extra) - } - } else { - return inbound.Remark } if s.showInfo { @@ -820,7 +838,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), "📊")) @@ -834,7 +852,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) { diff --git a/web/assets/js/model/dbinbound.js b/web/assets/js/model/dbinbound.js index 7f4f0812..d8d0b94f 100644 --- a/web/assets/js/model/dbinbound.js +++ b/web/assets/js/model/dbinbound.js @@ -137,8 +137,8 @@ class DBInbound { } } - get genInboundLinks() { + genInboundLinks(remarkModel) { const inbound = this.toInbound(); - return inbound.genInboundLinks(this.remark); + return inbound.genInboundLinks(this.remark,remarkModel); } } \ No newline at end of file diff --git a/web/assets/js/model/setting.js b/web/assets/js/model/setting.js index 06f66f81..61b7b532 100644 --- a/web/assets/js/model/setting.js +++ b/web/assets/js/model/setting.js @@ -11,6 +11,7 @@ class AllSetting { this.pageSize = 0; this.expireDiff = ""; this.trafficDiff = ""; + this.remarkModel = "-ieo"; this.tgBotEnable = false; this.tgBotToken = ""; this.tgBotChatId = ""; diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index 60fab197..240ed8f9 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -1352,20 +1352,28 @@ class Inbound extends XrayCommonClass { } } - genAllLinks(remark='', client){ + genAllLinks(remark='', remarkModel = '-ieo', client){ let result = []; let email = client ? client.email : ''; let addr = !ObjectUtil.isEmpty(this.listen) && this.listen !== "0.0.0.0" ? this.listen : location.hostname; - let port = this.port + let port = this.port; + const separationChar = remarkModel.charAt(0); + const orderChars = remarkModel.slice(1); + let orders = { + 'i': remark, + 'e': client ? client.email : '', + 'o': '', + }; if(ObjectUtil.isArrEmpty(this.stream.externalProxy)){ - let r = [remark, email].filter(x => x.length > 0).join('-'); + let r = orderChars.split('').map(char => orders[char]).filter(x => x.length > 0).join(separationChar); result.push({ remark: r, link: this.genLink(addr, port, 'same', r, client) }); } else { this.stream.externalProxy.forEach((ep) => { - let r = [remark, email, ep.remark].filter(x => x.length > 0).join('-') + orders['o'] = ep.remark; + let r = orderChars.split('').map(char => orders[char]).filter(x => x.length > 0).join(separationChar); result.push({ remark: r, link: this.genLink(ep.dest, ep.port, ep.forceTls, r, client) @@ -1375,11 +1383,11 @@ class Inbound extends XrayCommonClass { return result; } - genInboundLinks(remark = '') { + genInboundLinks(remark = '', remarkModel = '-ieo') { if(this.clients){ let links = []; this.clients.forEach((client) => { - this.genAllLinks(remark,client).forEach(l => { + this.genAllLinks(remark,remarkModel,client).forEach(l => { links.push(l.link); }) }); diff --git a/web/entity/entity.go b/web/entity/entity.go index 9b45c1ad..80735c2f 100644 --- a/web/entity/entity.go +++ b/web/entity/entity.go @@ -25,6 +25,7 @@ type AllSetting struct { PageSize int `json:"pageSize" form:"pageSize"` ExpireDiff int `json:"expireDiff" form:"expireDiff"` TrafficDiff int `json:"trafficDiff" form:"trafficDiff"` + RemarkModel string `json:"remarkModel" form:"remarkModel"` TgBotEnable bool `json:"tgBotEnable" form:"tgBotEnable"` TgBotToken string `json:"tgBotToken" form:"tgBotToken"` TgBotChatId string `json:"tgBotChatId" form:"tgBotChatId"` diff --git a/web/html/common/qrcode_modal.html b/web/html/common/qrcode_modal.html index 75657301..9502e320 100644 --- a/web/html/common/qrcode_modal.html +++ b/web/html/common/qrcode_modal.html @@ -32,7 +32,7 @@ this.client = client; this.subId = ''; this.qrcodes = []; - this.inbound.genAllLinks(this.dbInbound.remark, client).forEach(l => { + this.inbound.genAllLinks(this.dbInbound.remark, app.remarkModel, client).forEach(l => { this.qrcodes.push({ remark: l.remark, link: l.link diff --git a/web/html/xui/inbound_info_modal.html b/web/html/xui/inbound_info_modal.html index ecfd867c..650b4c58 100644 --- a/web/html/xui/inbound_info_modal.html +++ b/web/html/xui/inbound_info_modal.html @@ -263,7 +263,7 @@ this.clientSettings = this.inbound.clients ? this.inbound.clients[index] : null; this.isExpired = this.inbound.clients ? this.inbound.isExpiry(index): this.dbInbound.isExpiry; this.clientStats = this.inbound.clients ? this.dbInbound.clientStats.find(row => row.email === this.clientSettings.email) : []; - this.links = this.inbound.genAllLinks(this.dbInbound.remark, this.clientSettings); + this.links = this.inbound.genAllLinks(this.dbInbound.remark, app.remarkModel, this.clientSettings); if (this.clientSettings) { if (this.clientSettings.subId) { this.subLink = this.genSubLink(this.clientSettings.subId); diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html index 114eef67..a33e076f 100644 --- a/web/html/xui/inbounds.html +++ b/web/html/xui/inbounds.html @@ -554,6 +554,7 @@ enable : false, subURI : '' }, + remarkModel: '-ieo', tgBotEnable: false, showAlert: false, pageSize: 0, @@ -599,6 +600,7 @@ subURI: subURI }; this.pageSize = pageSize; + this.remarkModel = remarkModel; } }, setInbounds(dbInbounds) { @@ -1173,7 +1175,7 @@ inboundLinks(dbInboundId) { dbInbound = this.dbInbounds.find(row => row.id === dbInboundId); newDbInbound = this.checkFallback(dbInbound); - txtModal.show('{{ i18n "pages.inbounds.export"}}', newDbInbound.genInboundLinks, newDbInbound.remark); + txtModal.show('{{ i18n "pages.inbounds.export"}}', newDbInbound.genInboundLinks(this.remarkModel), newDbInbound.remark); }, importInbound() { promptModal.open({ @@ -1190,7 +1192,7 @@ exportAllLinks() { let copyText = []; for (const dbInbound of this.dbInbounds) { - copyText.push(dbInbound.genInboundLinks); + copyText.push(dbInbound.genInboundLinks(this.remarkModel)); } txtModal.show('{{ i18n "pages.inbounds.export"}}', copyText.join('\r\n'), 'All-Inbounds'); }, diff --git a/web/html/xui/settings.html b/web/html/xui/settings.html index 7aa3350c..50fc6c26 100644 --- a/web/html/xui/settings.html +++ b/web/html/xui/settings.html @@ -77,6 +77,28 @@ + + + + + + + + + + + [[ value ]] + + + [[ key ]] + + + + + @@ -93,7 +115,6 @@ -