fix: get client reverse tag in the outbound

This commit is contained in:
MHSanaei
2026-05-06 00:43:47 +02:00
parent 8bea0fde2b
commit 50603fd430
5 changed files with 38 additions and 6 deletions

View File

@@ -71,14 +71,19 @@ func (a *XraySettingController) getXraySetting(c *gin.Context) {
jsonMsg(c, I18nWeb(c, "pages.settings.toasts.getSettings"), err)
return
}
clientReverseTags, err := a.InboundService.GetClientReverseTags()
if err != nil {
clientReverseTags = "[]"
}
outboundTestUrl, _ := a.SettingService.GetXrayOutboundTestUrl()
if outboundTestUrl == "" {
outboundTestUrl = "https://www.google.com/generate_204"
}
xrayResponse := map[string]interface{}{
"xraySetting": json.RawMessage(xraySetting),
"inboundTags": json.RawMessage(inboundTags),
"outboundTestUrl": outboundTestUrl,
xrayResponse := map[string]any{
"xraySetting": json.RawMessage(xraySetting),
"inboundTags": json.RawMessage(inboundTags),
"clientReverseTags": json.RawMessage(clientReverseTags),
"outboundTestUrl": outboundTestUrl,
}
result, err := json.Marshal(xrayResponse)
if err != nil {

View File

@@ -204,6 +204,13 @@
if (app.enableDNS && !ObjectUtil.isEmpty(app.dnsTag)) this.inboundTags.push(app.dnsTag)
this.outboundTags = ["", ...app.templateSettings.outbounds.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj =>
obj.tag)];
if (app.clientReverseTags) {
app.clientReverseTags.forEach(tag => {
if (tag && !this.outboundTags.includes(tag)) {
this.outboundTags.push(tag);
}
});
}
this.balancerTags = [""];
if (app.templateSettings.routing && app.templateSettings.routing.balancers) {
this.balancerTags = ["", ...app.templateSettings.routing.balancers.filter((o) => !ObjectUtil.isEmpty(o.tag))

View File

@@ -280,6 +280,7 @@
outboundTestUrl: 'https://www.google.com/generate_204',
oldOutboundTestUrl: 'https://www.google.com/generate_204',
inboundTags: [],
clientReverseTags: [],
outboundsTraffic: [],
outboundTestStates: {}, // Track testing state and results for each outbound
saveBtnDisable: true,
@@ -559,6 +560,7 @@
this.oldXraySetting = xs;
this.xraySetting = xs;
this.inboundTags = result.inboundTags;
this.clientReverseTags = result.clientReverseTags || [];
this.outboundTestUrl = result.outboundTestUrl || 'https://www.google.com/generate_204';
this.oldOutboundTestUrl = this.outboundTestUrl;
this.saveBtnDisable = true;

View File

@@ -1764,6 +1764,24 @@ func (s *InboundService) GetInboundTags() (string, error) {
return string(tags), nil
}
func (s *InboundService) GetClientReverseTags() (string, error) {
db := database.GetDB()
var rawTags []string
err := db.Raw(`
SELECT DISTINCT JSON_EXTRACT(client.value, '$.reverse.tag')
FROM inbounds,
JSON_EACH(JSON_EXTRACT(inbounds.settings, '$.clients')) AS client
WHERE inbounds.protocol = 'vless'
AND JSON_EXTRACT(client.value, '$.reverse.tag') IS NOT NULL
AND JSON_EXTRACT(client.value, '$.reverse.tag') != ''
`).Scan(&rawTags).Error
if err != nil && err != gorm.ErrRecordNotFound {
return "[]", err
}
result, _ := json.Marshal(rawTags)
return string(result), nil
}
func (s *InboundService) MigrationRemoveOrphanedTraffics() {
db := database.GetDB()
db.Exec(`