feat(inbounds): improve multi-node online attribution (#6164)

This commit is contained in:
isultanov99
2026-08-15 17:40:35 +02:00
committed by GitHub
parent 2d669fa4b7
commit be70535b94
5 changed files with 399 additions and 21 deletions
+14 -2
View File
@@ -698,8 +698,13 @@ type TrafficSnapshot struct {
// OnlineEmails so the master can attribute deeply nested clients to the real
// node across a chain (#4983). Empty when the node is an old build without
// the per-GUID endpoint — OnlineEmails is the fallback then.
OnlineTree map[string][]string
LastOnlineMap map[string]int64
OnlineTree map[string][]string
// ActiveInboundTree is the GUID-keyed subtree of inbound tags that carried
// traffic within the node's online grace window. Empty when the node is an
// old build without the endpoint; the master then falls back to email-only
// online attribution for that node.
ActiveInboundTree map[string][]string
LastOnlineMap map[string]int64
// HostGroups carries the node's per-inbound host overrides (TLS/SNI/
// fingerprint), fetched only when the snapshot holds a not-yet-adopted tag.
HostGroups []*entity.HostGroup
@@ -754,6 +759,13 @@ func (r *Remote) FetchTrafficSnapshot(ctx context.Context) (*TrafficSnapshot, er
_ = json.Unmarshal(envLastOnline.Obj, &snap.LastOnlineMap)
}
envActiveInbounds, err := r.do(ctx, http.MethodPost, "panel/api/clients/activeInbounds", nil)
if err != nil {
logger.Debugf("remote %s active inbounds fetch failed: %v", r.node.Name, err)
} else if len(envActiveInbounds.Obj) > 0 {
_ = json.Unmarshal(envActiveInbounds.Obj, &snap.ActiveInboundTree)
}
return snap, nil
}