Skip to content

API: retrieve all online users with their IPs#5776

Open
kastov wants to merge 2 commits intoXTLS:mainfrom
kastov:feat/get-all-users-online-info
Open

API: retrieve all online users with their IPs#5776
kastov wants to merge 2 commits intoXTLS:mainfrom
kastov:feat/get-all-users-online-info

Conversation

@kastov
Copy link
Copy Markdown
Contributor

@kastov kastov commented Mar 8, 2026

Added methods to gRPC API and CLI command

Usage

./xray api statsonlineiplist --server=127.0.0.1:777 --all
{
    "users": [
        {
            "email": "alice@xray.com",
            "ips": [
                {
                    "ip": "3.3.3.3",
                    "lastSeen": 1772922476
                }
            ]
        }
    ]
}

@kastov kastov force-pushed the feat/get-all-users-online-info branch from bff4086 to 8751821 Compare March 8, 2026 14:02
@Fangliding
Copy link
Copy Markdown
Member

为什么不给 cmdOnlineStatsIpList 加一个 -all 的选项?

@kastov
Copy link
Copy Markdown
Contributor Author

kastov commented Mar 9, 2026

@Fangliding done

@Fangliding
Copy link
Copy Markdown
Member

。。。

@Fangliding Fangliding closed this Mar 9, 2026
@kastov
Copy link
Copy Markdown
Contributor Author

kastov commented Mar 9, 2026

@Fangliding why?

@kastov
Copy link
Copy Markdown
Contributor Author

kastov commented Mar 9, 2026

i removed new CLI method and extended existing (d963245) as you asked...

@Fangliding
Copy link
Copy Markdown
Member

Fangliding commented Mar 9, 2026

本来有一个用email query的选项 复用一下加个逻辑query全部不就行了 基础设施全在这里 结果你只是wrap了一下入口点 看起来你并没有考虑过内部的安排只是为了自己面板的需求让AI往核心堆垃圾然后打开PR

@Fangliding
Copy link
Copy Markdown
Member

Fangliding commented Mar 9, 2026

至于别的 你们已经有了webhook 我没有很反对它的原因是因为它的的确确是一个非常强大的功能 你们完全可以通过它在自己的软件里构建一个更为完善的在线系统(你们甚至可以追踪具体的访问时间 访问网站次数和频率) 而不是在core再添加一套API

@kastov
Copy link
Copy Markdown
Contributor Author

kastov commented Mar 9, 2026

if you meant to modify grpc method GetStatsOnlineIpList – changing it response type to array and make email optional – it will create breaking changes

@RPRX
Copy link
Copy Markdown
Member

RPRX commented Mar 30, 2026

赞助的力量

话说这个和现有 Online Map API 的区别在于?如果要 break 也不是不行反正都坏掉那么久了

@RPRX RPRX reopened this Mar 30, 2026
@kastov
Copy link
Copy Markdown
Contributor Author

kastov commented Mar 30, 2026

The existing Online Map API doesn't have a way to get all users with their IPs in a single call. Right now you need N+1: GetAllOnlineUsers (emails only, no IPs) → then GetStatsOnlineIpList per user.

GetAllUsersOnlineInfo returns everything in one request — users, IPs, last seen timestamps.

The OnlineMap interface refactor (List()/IPTimeMap()ForEach(), time.Timeint64) was done because I was targeting high-performance scenarios with frequent polling of this endpoint — the old methods allocated on every call and time.Time doesn't map to protobuf cleanly. But if this is too invasive, I can keep the existing interface untouched and implement GetAllUsersOnlineInfo on top of the current IPTimeMap() — it'll just be less efficient.

@TaiFil
Copy link
Copy Markdown

TaiFil commented Mar 30, 2026

It would be nice if there were a single complete query with ips, downlink, uplink:

./xray api statsonlinelist --server=127.0.0.1:777 --all
{
    "users": [
        {
            "email": "alice@xray.com",
            "ips": [
                {
                    "ip": "3.3.3.3",
                    "lastSeen": 1772922476
                }
            ],
            "uplink": 123,
            "downlink": 123
        }
    ]
}

@RPRX
Copy link
Copy Markdown
Member

RPRX commented Mar 31, 2026

实现上面这个 #5776 (comment) 来获取所有相关信息吧,加参数决定要不要仅 online 的、要不要流量统计,后续可继续扩展

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants