-
Notifications
You must be signed in to change notification settings - Fork 73
feat: Implement Per-Node Data Limits & Subscription Variables #215
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
base: dev
Are you sure you want to change the base?
Conversation
…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}
|
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 |
| for limit in limits | ||
| ] | ||
| etag_content = json.dumps(limits_data, sort_keys=True) | ||
| etag = f'"{hashlib.md5(etag_content.encode()).hexdigest()}"' |
Check failure
Code scanning / CodeQL
Use of a broken or weak cryptographic hashing algorithm on sensitive data High
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