Add UserConnTracker to manage user connection cancellations across proxies#5844
Add UserConnTracker to manage user connection cancellations across proxies#5844ImMohammad20000 wants to merge 11 commits intoXTLS:mainfrom
Conversation
|
#5401 连接追踪是会加的,不过怎么设计还要再考虑下 我看了下你的代码,为啥要 register unregister,每个 user 内存中自带一个 ctx 然后被 remove 时直接 cancel() 不就行了
|
|
I considered that approach, but I wanted to ensure connections are tracked across all proxies without relying on each inbound’s internal context, especially since the removal comes via gRPC API and the user might be referenced from multiple places. Using a separate tracker makes it explicit and easier to debug. Happy to refactor if you think a simpler ctx-based approach inside each user struct. |
|
这不就是个机场计费 helper |
|
|
Another pr and again you're trying to make people work looks like useless. |
|
这个加了后理论上能按 email 获取到 user 的所有活跃连接吧? |
yes you can do that too by counting the cancel functions |
|
在我看来 *ray 缺的一个重要功能是连接级相关的 API #5722 (comment) *ray 的 GUI 客户端都没有像 Clash/Mihomo 那样有显示哪些连接正在活跃、用了多少流量等 #5401 仅这个 PR 的话也可以接受,但如果一步到位把上述功能给实现了当然更好,@ImMohammad20000 有兴趣吗 |
AI时代代码又不值钱 AI堆垃圾反而负收益 我对这种只是为了售卖节点的功能一直不喜欢 只能说你们一直提交这样的pr 以后真有人来挖掘史山的时候会发现这里有一个看起来很高级的什么 conntrack 模块 结果翻一下调用唯一的作用就是为了在 remove user 的时候触发一个回调 |
|
堵不如疏吧,把一个仅机场能用的功能扩展为对 Xray 自身整体的完善,这个 PR 如果原样合并的话后续肯定也会被替代的 |
|
@RPRX I added a new package for connectiontracker also implemented some new apis |
|
全是AI写的你自己检查过么。。。 |
|
Its not all by ai and yes i checked the code before i push it |
|
|
My goal was a simple tracker that close the open connections And my second commit just added an api to the original disine |
|
这些奇奇怪怪的东西一定要全部糊进core里面吗 |
那你可以解释为什么 WrapConn 根本没地方调用吗 RegisterWithMeta 的第二个返回值根本没任何人使用 |
|
Any plan for this? |
|
我个人觉得这个功能是可以有的,但对其他人来说这么多代码目前只实现了这一个功能的话争议过大 Rebase 一下,顺便实现 #5401 做成一整套系统吧,会合并 |
|
如果 vibe 含量过高,我觉得还是谨慎点好 |
|
The implementation of connection tracking is rather messy. I agree that this is a necessary feature for a number of use cases. However, xray-core will never be able to fully implement this functionality for the other purposes connection tracking is usually used for. This amount of code, embedded into nearly every part of the codebase, is overkill created for a single task only: terminating user connections. As my dear BRAT kastov said, this functionality can be implemented independently without any particular issues. I will not comment on the quality of the code itself; I think everyone here understands that this is far from the best or most reliable solution. Nevertheless, since the code is already here, a few words about the specific implementation issues:
And that’s not all I found. |
|
我觉得虽然有些功能可以由外部程序调用 Xray API 加一些逻辑来实现,但若是非小众需求且是 |
…n management - Add protobuf definitions for connection tracking commands including ListConnections, CloseConnection, GetUserStats, and StreamConnections. - Generate gRPC client and server code from the protobuf definitions. - Implement a connection tracker that maintains active connections, allows forced disconnections, and provides real-time statistics. - Create API commands for listing connections, closing connections, streaming connection events, and retrieving user statistics. - Add tests for connection tracking functionality to ensure correctness and thread safety.
34d5cf6 to
7329bb9
Compare
|
nevermind |
|
Its done @RPRX |
there is an old bug that lead to a big issue in panels that leve connections open when users remove from inbounds via gRPC api the connection to that user dose not close in some cases so i implement a connection tracker that track all connections and close theme when users remove from the inbounds
an example of the issue is user limited to 1GB but becouse connections not closed it used 18GB