Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Add user IPs and access times tracking #4360

Merged
merged 6 commits into from
Feb 7, 2025

Conversation

mr1cloud
Copy link
Contributor

@mr1cloud mr1cloud commented Feb 6, 2025

Added IpTimeMap method, GetStatsOnlineIpList RPC and CLI command for tracking client IPs and access times.

Execute:

.\xray.exe api statsonlineiplist -server="127.0.0.1:8080" -email user1

Result:

{
    "ips": {
        "192.168.1.2": {
            "seconds": "1738845962",
            "nanos": 572060848
        }
    },
    "name": "user>>>user1>>>online"
}

New PR after corrections from #4347

@RPRX
Copy link
Member

RPRX commented Feb 6, 2025

应当把它放在 command 文件夹下面并把 metadata 改为 Xray 的,还有这个文件复制进来没有 license 问题吧

@RPRX
Copy link
Member

RPRX commented Feb 6, 2025

你改好后,这个 PR 我来合并(时机成熟时,现在 main 在搞 MMDF)

@yuhan6665
Copy link
Member

Guys please don't copy protobuf code in project.
protocolbuffers/protobuf#5131

@mr1cloud
Copy link
Contributor Author

mr1cloud commented Feb 6, 2025

@yuhan6665 I did that last time, but my PR was canceled: #4347
Then how to work with ptorobuf in this project, I would appreciate an explanation.

@RPRX
Copy link
Member

RPRX commented Feb 6, 2025

可以换成自定义的结构吗?不引用外部 proto

@mr1cloud
Copy link
Contributor Author

mr1cloud commented Feb 6, 2025

Yes, i can do it. I'll just say it again, @yuhan6665 told me to use google protobuf, so that's what I did...

@yuhan6665
Copy link
Member

Please don't define your own timestamp, use protobuf version, properly.

@mr1cloud
Copy link
Contributor Author

mr1cloud commented Feb 6, 2025

@yuhan6665 like I did last time, right? #4347

@RPRX
Copy link
Member

RPRX commented Feb 6, 2025

我不太了解 proto 这里是怎么回事

那如果引用外部 proto,执行 go run ./infra/vprotogen 前都要先把那个外部 proto 拉到本地?

@mr1cloud
Copy link
Contributor Author

mr1cloud commented Feb 6, 2025

@RPRX It turns out that it is...

@RPRX
Copy link
Member

RPRX commented Feb 6, 2025

所以 google standard timestamp 有什么特别的好处吗?我们不是只需要 timestamp 的值而已?

@mr1cloud
Copy link
Contributor Author

mr1cloud commented Feb 6, 2025

Initially, I just did the display in seconds, but I was told to use google timestamp. I did so, everything was accepted, but there was a rollback due to the lack of file data during execution: go run ./infra/vprotogen

@RPRX
Copy link
Member

RPRX commented Feb 6, 2025

我想了解下 @yuhan6665 的看法,或许这里我们只是需要一个值?

@RPRX
Copy link
Member

RPRX commented Feb 6, 2025

如果需要先拉下来外部 proto 就比较难受了,我经常 go run ./infra/vprotogen

@yuhan6665
Copy link
Member

Using google protobuf is not rocket science, I'm sure we (whoever run into issue) can fix it.
I'm just saying this PR copying of timestamp is not proper usage

@RPRX
Copy link
Member

RPRX commented Feb 6, 2025

主要是看到了 then convert the time.Time to standard google.protobuf.Timestamp

既然没有特别的需求,直接拿个 uint64 存 timestamp 吧

@mr1cloud
Copy link
Contributor Author

mr1cloud commented Feb 6, 2025

So I'm just returning the timestamp in uint64?

@Fangliding
Copy link
Member

timestamp轻松加愉快为什么要搞个这个东西进来

@mr1cloud
Copy link
Contributor Author

mr1cloud commented Feb 6, 2025

No no, I'll just return the timestamp (uint64), okey?

@RPRX
Copy link
Member

RPRX commented Feb 7, 2025

timestamp轻松加愉快为什么要搞个这个东西进来

没看懂

@RPRX
Copy link
Member

RPRX commented Feb 7, 2025

@mr1cloud just uint64

…d update related code to use uint64 for IP timestamps.
@mr1cloud
Copy link
Contributor Author

mr1cloud commented Feb 7, 2025

Okay, I think that's it.

Execute:

.\xray.exe api statsonlineiplist -server="127.0.0.1:8080" -email user1

Result:

{
    "ips": {
        "192.168.1.2": 1738924438
    },
    "name": "user>>>user1>>>online"
}

@RPRX
Copy link
Member

RPRX commented Feb 7, 2025

改成 int64 吧,不用转换类型了

@RPRX RPRX merged commit e893fa1 into XTLS:main Feb 7, 2025
35 checks passed
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