diff --git a/web/controller/xui.go b/web/controller/xui.go index fc3ca5f8..1844181d 100644 --- a/web/controller/xui.go +++ b/web/controller/xui.go @@ -23,7 +23,7 @@ func (a *XUIController) initRouter(g *gin.RouterGroup) { g.GET("/", a.index) g.GET("/inbounds", a.inbounds) - g.GET("/setting", a.setting) + g.GET("/settings", a.settings) a.inboundController = NewInboundController(g) a.settingController = NewSettingController(g) @@ -37,6 +37,6 @@ func (a *XUIController) inbounds(c *gin.Context) { html(c, "inbounds.html", "pages.inbounds.title", nil) } -func (a *XUIController) setting(c *gin.Context) { - html(c, "setting.html", "pages.settings.title", nil) +func (a *XUIController) settings(c *gin.Context) { + html(c, "settings.html", "pages.settings.title", nil) } diff --git a/web/service/config.json b/web/service/config.json index a986ea94..87069239 100644 --- a/web/service/config.json +++ b/web/service/config.json @@ -3,22 +3,18 @@ "loglevel": "warning" }, "api": { - "services": [ - "HandlerService", - "LoggerService", - "StatsService" - ], - "tag": "api" + "tag": "api", + "services": ["HandlerService", "LoggerService", "StatsService"] }, "inbounds": [ { + "tag": "api", "listen": "127.0.0.1", "port": 62789, "protocol": "dokodemo-door", "settings": { "address": "127.0.0.1" - }, - "tag": "api" + } } ], "outbounds": [ @@ -27,16 +23,16 @@ "settings": {} }, { + "tag": "blocked", "protocol": "blackhole", - "settings": {}, - "tag": "blocked" + "settings": {} } ], "policy": { "levels": { "0": { - "statsUserUplink": true, - "statsUserDownlink": true + "statsUserDownlink": true, + "statsUserUplink": true } }, "system": { @@ -48,25 +44,19 @@ "domainStrategy": "IPIfNonMatch", "rules": [ { - "inboundTag": [ - "api" - ], - "outboundTag": "api", - "type": "field" + "type": "field", + "inboundTag": ["api"], + "outboundTag": "api" }, { - "ip": [ - "geoip:private" - ], + "type": "field", "outboundTag": "blocked", - "type": "field" + "ip": ["geoip:private"] }, { + "type": "field", "outboundTag": "blocked", - "protocol": [ - "bittorrent" - ], - "type": "field" + "protocol": ["bittorrent"] } ] }, diff --git a/web/service/sub.go b/web/service/sub.go index f887c681..53099497 100644 --- a/web/service/sub.go +++ b/web/service/sub.go @@ -38,7 +38,7 @@ func (s *SubService) GetSubs(subId string, host string) ([]string, string, error continue } for _, client := range clients { - if client.SubID == subId { + if client.Enable && client.SubID == subId { link := s.getLink(inbound, client.Email) result = append(result, link) clientTraffics = append(clientTraffics, s.getClientTraffics(inbound.ClientStats, client.Email)) @@ -73,7 +73,7 @@ func (s *SubService) GetSubs(subId string, host string) ([]string, string, error func (s *SubService) getInboundsBySubId(subId string) ([]*model.Inbound, error) { db := database.GetDB() var inbounds []*model.Inbound - err := db.Model(model.Inbound{}).Preload("ClientStats").Where("settings like ?", fmt.Sprintf(`%%"subId": "%s"%%`, subId)).Find(&inbounds).Error + err := db.Model(model.Inbound{}).Preload("ClientStats").Where("settings like ? and enable = ?", fmt.Sprintf(`%%"subId": "%s"%%`, subId), true).Find(&inbounds).Error if err != nil && err != gorm.ErrRecordNotFound { return nil, err } @@ -107,9 +107,10 @@ func (s *SubService) genVmessLink(inbound *model.Inbound, email string) string { if inbound.Protocol != model.VMess { return "" } + remark := fmt.Sprintf("%s-%s", inbound.Remark, email) obj := map[string]interface{}{ "v": "2", - "ps": email, + "ps": remark, "add": s.address, "port": inbound.Port, "type": "none", @@ -353,7 +354,8 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string { // Set the new query values on the URL url.RawQuery = q.Encode() - url.Fragment = email + remark := fmt.Sprintf("%s-%s", inbound.Remark, email) + url.Fragment = remark return url.String() } @@ -502,7 +504,8 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string // Set the new query values on the URL url.RawQuery = q.Encode() - url.Fragment = email + remark := fmt.Sprintf("%s-%s", inbound.Remark, email) + url.Fragment = remark return url.String() } @@ -583,7 +586,8 @@ func (s *SubService) genShadowsocksLink(inbound *model.Inbound, email string) st // Set the new query values on the URL url.RawQuery = q.Encode() - url.Fragment = clients[clientIndex].Email + remark := fmt.Sprintf("%s-%s", inbound.Remark, clients[clientIndex].Email) + url.Fragment = remark return url.String() }