Skip to content

feat: Track user traffic per node (server_id)#755

Open
socksprox wants to merge 6 commits intocedar2025:masterfrom
socksprox:feat/server-id-stat-user
Open

feat: Track user traffic per node (server_id)#755
socksprox wants to merge 6 commits intocedar2025:masterfrom
socksprox:feat/server-id-stat-user

Conversation

@socksprox
Copy link

This PR adds per-node user traffic tracking by adding a server_id column to the v2_stat_user table.

Changes

  1. Add server_id to stat_user - Track which node the traffic came from
  2. Update unique constraint - Ensure traffic from different nodes is not merged together

Files changed

  • app/Models/StatUser.php - Added server_id to fillable
  • app/Jobs/StatUserJob.php - Include server_id when recording stats
  • database/migrations/2025_11_29_000000_add_server_id_to_stat_user.php - Add column
  • database/migrations/2025_11_29_120000_update_stat_user_unique_constraint.php - Update unique index

@socksprox
Copy link
Author

@cedar2025 Traffic will now be reported per node, so admins can know if a user used a lot of traffic, but on a very cheap node, or if he used much on an expensive one. This can be used with plugins and so on.

The API and Admin panel are not affected, it is only in the DB for now.

If you would give me the source for the admin panel, i could add it, otherwise i can't. But please merge this change, would love that :)

socksprox added 4 commits November 29, 2025 14:07
@socksprox
Copy link
Author

  • New:
    The api now behaves exactly like before, the new node entries are combined, so every entry is still one day, except if the rate is different, exactly like before.

@socksprox
Copy link
Author

IMG_5757

Here a screenshot of whats possible with the new data. Since I cannot edit the admin panel, I chose to not modify any API:

But please take this pull request, then you can modify the admin panel and add this properly, or just keep it like that. I for myself just built a plugin that extends the admin panel so i have the data

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.

1 participant