mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-21 20:16:08 +00:00
fix(online): scope per-inbound online to inbounds that carried traffic
Multi-inbound clients showed online on every inbound they were attached to. Xray's user-level traffic stat aggregates across all inbounds a client belongs to, so the email signal alone can't say which inbound was used. Pair it with the inbound-level traffic signal under the same 20s grace and gate the per-inbound rollup on it: a client only shows online on inbounds that actually moved bytes this window. Remote nodes report no per-inbound activity and stay ungated (no regression). Adds GetActiveInboundsByNode, the activeInbounds WS field and POST /panel/api/clients/activeInbounds. Fixes #4859
This commit is contained in:
+14
-6
@@ -3339,6 +3339,13 @@ func (s *InboundService) GetOnlineClientsByNode() map[int][]string {
|
||||
return p.GetOnlineClientsByNode()
|
||||
}
|
||||
|
||||
func (s *InboundService) GetActiveInboundsByNode() map[int][]string {
|
||||
if p == nil {
|
||||
return map[int][]string{}
|
||||
}
|
||||
return p.GetActiveInboundsByNode()
|
||||
}
|
||||
|
||||
func (s *InboundService) SetNodeOnlineClients(nodeID int, emails []string) {
|
||||
if p != nil {
|
||||
p.SetNodeOnlineClients(nodeID, emails)
|
||||
@@ -3365,13 +3372,14 @@ func (s *InboundService) GetClientsLastOnline() (map[string]int64, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// RefreshLocalOnlineClients folds the emails active on this panel's own
|
||||
// xray this poll into the local online set, applying the grace window and
|
||||
// pruning stale entries. Pass nil to only prune. See xray.Process for why
|
||||
// the local set is kept separate from the shared last_online column.
|
||||
func (s *InboundService) RefreshLocalOnlineClients(activeEmails []string) {
|
||||
// RefreshLocalOnlineClients folds the emails and inbound tags active on this
|
||||
// panel's own xray this poll into the local online/active sets, applying the
|
||||
// grace window and pruning stale entries. Pass nil to only prune. See
|
||||
// xray.Process for why the local sets are kept separate from the shared
|
||||
// last_online column.
|
||||
func (s *InboundService) RefreshLocalOnlineClients(activeEmails, activeInboundTags []string) {
|
||||
if p != nil {
|
||||
p.RefreshLocalOnline(activeEmails, time.Now().UnixMilli(), onlineGracePeriodMs)
|
||||
p.RefreshLocalOnline(activeEmails, activeInboundTags, time.Now().UnixMilli(), onlineGracePeriodMs)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user