Skip to content

Comments

API: Add user IPs and access times tracking#4347

Merged
yuhan6665 merged 3 commits intoXTLS:mainfrom
mr1cloud:client-iplist-last-connected-time
Feb 5, 2025
Merged

API: Add user IPs and access times tracking#4347
yuhan6665 merged 3 commits intoXTLS:mainfrom
mr1cloud:client-iplist-last-connected-time

Conversation

@mr1cloud
Copy link
Contributor

@mr1cloud mr1cloud commented Feb 3, 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": 13
    },
    "name": "user>>>user1>>>online"
}

Maybe this functionality will come in handy.

@RPRX RPRX requested a review from yuhan6665 February 4, 2025 02:57
@mr1cloud mr1cloud changed the title API: Add user IPs and access times tracing API: Add user IPs and access times tracking Feb 4, 2025
@ImMohammad20000
Copy link

ImMohammad20000 commented Feb 4, 2025

could you add a method to get all online users by one single request,
Geting online users one by one is very hard when you have so many users and implementing this in panels is difficult.

@mr1cloud
Copy link
Contributor Author

mr1cloud commented Feb 4, 2025

@ImMohammad20000 yes, I will make this functionality, but first I would like to see if this request is accepted from me.

Copy link
Member

@yuhan6665 yuhan6665 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR, please take a look at the comment

return list
}

func (c *OnlineMap) IpTimeMap() map[string]int64 {
Copy link
Member

@yuhan6665 yuhan6665 Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should just return the ipList map[string]time.Time
then convert the time.Time to standard google.protobuf.Timestamp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that is, to return not seconds, but a timestamp from the last online session without reference to 20 seconds of cleaning?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right just return raw values, caller can do convert as they need

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey :)

@mr1cloud
Copy link
Contributor Author

mr1cloud commented Feb 4, 2025

@yuhan6665 check it please, thanks.

@mr1cloud mr1cloud requested a review from yuhan6665 February 4, 2025 17:29
@yuhan6665 yuhan6665 merged commit 4582930 into XTLS:main Feb 5, 2025
35 checks passed
@yuhan6665
Copy link
Member

Looks good! Thanks again

@mr1cloud
Copy link
Contributor Author

mr1cloud commented Feb 5, 2025

@yuhan6665 I love doing this for this project and the community!

@RPRX
Copy link
Member

RPRX commented Feb 6, 2025

合并这个 PR 后 go run ./infra/vprotogen 报错:

google/protobuf/timestamp.proto: File not found.
app/stats/command/command.proto:9:1: Import "google/protobuf/timestamp.proto" was not found or had errors.
app/stats/command/command.proto: "google.protobuf.Timestamp" is not defined.

且 protoc 和 protoc-gen-go 应与 main 一致,4582930 会被我 force 掉,请重开一个 PR

@mr1cloud
Copy link
Contributor Author

mr1cloud commented Feb 6, 2025

@RPRX Could you tell me if I understood correctly, I need to place google/protobuf/timestamp.proto in the project and then everything will be fine?

@RPRX
Copy link
Member

RPRX commented Feb 6, 2025

@mr1cloud 应该是这样

@RPRX
Copy link
Member

RPRX commented Feb 6, 2025

@mr1cloud 或者你直接把内容复制进现有 proto

@mr1cloud
Copy link
Contributor Author

mr1cloud commented Feb 6, 2025

@RPRX thank you! I'll fix it now.

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