Skip to content

Conversation

@Rerowros
Copy link

@Rerowros Rerowros commented Jan 17, 2026

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

  • Database: Added NodeUserLimit model and migrations. Added user_data_limit to Node
  • Logic:
    • Implemented priority system: Individual Limit > Template Limit > Node Default.
    • Added logic to propagate Node.user_data_limit changes to relevant users.
    • Fixed user creation/modification from templates to correctly apply node limits.
  • API:
    • Added endpoints for managing node user limits.
    • Added POST /api/user/{username}/reset-usage-by-node endpoint.
  • UI:
    • Added "User Limits" manager in User Modal.
    • Added "Traffic by Node" breakdown.
    • Added per-node settings in Node Modal.
  • Subscription:
    • Added per-node variables for Hosts (Remarks/Address/Path):
      • {NODE_USAGE_N}, {NODE_LIMIT_N}, {NODE_LEFT_N} (where N is node ID).
      • {NODE_NAME_N}.

Related PRs

Closes #212

@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…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}
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