feat: Implement Per-Node Data Limits & Subscription Variables#214
Closed
Rerowros wants to merge 11 commits intoPasarGuard:devfrom
Closed
feat: Implement Per-Node Data Limits & Subscription Variables#214Rerowros wants to merge 11 commits intoPasarGuard:devfrom
Rerowros wants to merge 11 commits intoPasarGuard:devfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Jan 17, 2026
5db63b2 to
7f0399f
Compare
…mits - Add NodeUserLimit model for per-user per-node traffic limits - Add node_user_limits field to UserTemplate model - Add user_data_limit, user_data_limit_reset_strategy, user_reset_time to Node model - Add migrations for all schema changes
- Add node_user_limit.py with get, create, modify, delete, upsert functions - Add reset_user_node_usage to user.py for per-node usage reset - Update user create to apply Node.user_data_limit defaults - Add node_user_limits field handling to user_template
- Add _apply_node_limits_from_template using upsert for template priority - Add _propagate_user_data_limit_change for Node.user_data_limit updates - Add reset_user_node_usage operation method - Fix MissingGreenlet errors with awaitable_attrs and proper refresh - Update core_users to filter users by per-node limits
- Add /api/node-user-limits router with CRUD endpoints
- Add /api/user/{username}/reset-usage-by-node endpoint
- Add /api/user/{username}/node-limits and node-traffic endpoints
- Add ResetNodeUsageRequest model
- Add limit_enforcer settings to General model
- Add NodeLimitsManager component for user modal - Add node-user-limits table and dialog components - Add reset-usage-dialog for per-node usage reset - Add traffic-modal for viewing node traffic breakdown - Update node-modal with user_data_limit fields - Update user-template-modal with node_user_limits support - Add translations for en and ru locales
- Add test_template_fix.py for node_user_limits template tests - Add test_limits_fix.py for node data limit tests - Update conftest and helpers for test infrastructure
- Add _apply_node_limits_from_template call to modify_user_with_template - Add traffic_by_node translation to en.json and ru.json
- Add NODE_USAGE_N, NODE_LIMIT_N, NODE_LEFT_N, NODE_NAME_N variables
- Add node_traffic field to UsersResponseWithInbounds
- Load per-node usage and limits in validated_user
- Variables can be used in host remarks like {NODE_USAGE_1}/{ NODE_LIMIT_1}
7f0399f to
a134d05
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements full support for per-node data limits (
user_data_limit), allowing granular traffic control for users on specific nodes. It also adds dynamic variables for subscription hosts.Key Changes
NodeUserLimitmodel and migrations. Addeduser_data_limitto NodeNode.user_data_limitchanges to relevant users.POST /api/user/{username}/reset-usage-by-nodeendpoint.{NODE_USAGE_N},{NODE_LIMIT_N},{NODE_LEFT_N}(where N is node ID).{NODE_NAME_N}.Related PRs
Closes #212