Skip to content

Conversation

@Rerowros
Copy link

@Rerowros Rerowros commented Jan 17, 2026

Summary

Updates the gRPC service definitions to support per-node limit configuration.

Changes

  • Updated service.proto with new fields for limit enforcement params.
  • Regenerated service_pb2.py and service_grpc.py.
  • Updated abstract node interface signatures.

Related PRs

Summary by CodeRabbit

  • New Features
    • Node startup configuration has been enhanced with new optional limit enforcement settings: node identifier, panel API endpoint URL, limit check interval, and refresh interval (all configurable in seconds). All parameters are entirely optional with intelligent defaults, providing advanced configuration flexibility and control while preserving complete backward compatibility with all existing deployments.

✏️ Tip: You can customize this high-level summary in your review settings.

- Update service.proto with node_id, panel_api_url, limit params
- Regenerate service_pb2.py and service_grpc.py
- Update abstract_node.py with limit enforcer params
- Update grpclib.py and rest.py with new start method signature
@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

Walkthrough

Configuration parameters for limit enforcement (node_id, panel_api_url, limit_check_interval, limit_refresh_interval) are added to the PasarGuardNode.start method signature across the abstract interface and concrete implementations, with corresponding protobuf message schema updates to transmit these settings.

Changes

Cohort / File(s) Summary
Protocol & Type Definitions
PasarGuardNodeBridge/common/service.proto, PasarGuardNodeBridge/common/service_pb2.py, PasarGuardNodeBridge/common/service_pb2.pyi
Backend protobuf message extended with four new fields: node_id (int32), panel_api_url (string), limit_check_interval (int32, default 30s), and limit_refresh_interval (int32, default 60s); generated Python descriptor and type stubs updated accordingly.
Abstract Interface
PasarGuardNodeBridge/abstract_node.py
PasarGuardNode.start() abstract method signature expanded with four optional limit enforcer configuration parameters following the existing timeout parameter.
Concrete Implementations
PasarGuardNodeBridge/grpclib.py, PasarGuardNodeBridge/rest.py
Node.start() method signatures updated to accept and propagate the four new limit enforcer configuration parameters into the Backend request payload.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Four little parameters, hopping so bright,
node_id and panel_api_url take flight,
limit_check and refresh in intervals tight,
Configuration flows through each file with delight,
The bridge now enforces with all of its might! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: updating gRPC definitions to support limit enforcer configuration across multiple files.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@PasarGuardNodeBridge/common/service.proto`:
- Around line 26-31: The proto comments saying "default 30/60" are misleading
because proto3 scalars decode to zero; update handling for the fields
limit_check_interval and limit_refresh_interval so zero values don't become
0-second intervals: either change the proto to use optional or wrapper types
(e.g., google.protobuf.Int32Value) for limit_check_interval and
limit_refresh_interval so presence can be detected, or keep scalars but add
normalization logic in the node/panel code that reads node_id, panel_api_url,
limit_check_interval, and limit_refresh_interval and replaces 0 with the
intended defaults (30 and 60) before using them.
🧹 Nitpick comments (2)
PasarGuardNodeBridge/rest.py (1)

115-149: Avoid mutable default for exclude_inbounds.

Using a list literal as a default argument can leak state across calls. Prefer None and initialize inside the method.

♻️ Proposed fix
-    async def start(
+    async def start(
         self,
         config: str,
         backend_type: service.BackendType,
         users: list[service.User],
         keep_alive: int = 0,
-        exclude_inbounds: list[str] = [],
+        exclude_inbounds: list[str] | None = None,
         timeout: int | None = None,
         # Limit enforcer configuration (optional - sent to node for real-time enforcement)
         node_id: int = 0,
         panel_api_url: str = "",
         limit_check_interval: int = 30,
         limit_refresh_interval: int = 60,
     ):
         """Start the node with proper task management"""
         timeout = timeout or self._default_timeout
+        exclude_inbounds = exclude_inbounds or []
PasarGuardNodeBridge/grpclib.py (1)

100-130: Avoid mutable default for exclude_inbounds.

Use None + initialization to avoid shared state across calls.

♻️ Proposed fix
-    async def start(
+    async def start(
         self,
         config: str,
         backend_type: service.BackendType,
         users: list[service.User],
         keep_alive: int = 0,
-        exclude_inbounds: list[str] = [],
+        exclude_inbounds: list[str] | None = None,
         timeout: int | None = None,
         # Limit enforcer configuration (optional - sent to node for real-time enforcement)
         node_id: int = 0,
         panel_api_url: str = "",
         limit_check_interval: int = 30,
         limit_refresh_interval: int = 60,
     ) -> service.BaseInfoResponse | None:
         """Start the node with proper task management"""
         timeout = timeout or self._default_timeout
+        exclude_inbounds = exclude_inbounds or []

Comment on lines +26 to +31

// Limit enforcer configuration (sent from panel)
int32 node_id = 6;
string panel_api_url = 7;
int32 limit_check_interval = 8; // seconds, default 30
int32 limit_refresh_interval = 9; // seconds, default 60
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Proto3 “default” comments are not enforced.

In proto3, scalar fields default to zero on decode; the “default 30/60” comments won’t apply unless the server/client normalizes. This can lead to 0-second intervals if another client omits the fields.

Consider either:

  • Normalizing 0 to 30/60 in the node/panel logic, or
  • Using optional/wrapper types to detect presence.
💡 Minimal clarification (comment-only) if you keep current schema
-  int32 limit_check_interval = 8;   // seconds, default 30
-  int32 limit_refresh_interval = 9; // seconds, default 60
+  int32 limit_check_interval = 8;   // seconds; 0 means "use default" (e.g., 30)
+  int32 limit_refresh_interval = 9; // seconds; 0 means "use default" (e.g., 60)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Limit enforcer configuration (sent from panel)
int32 node_id = 6;
string panel_api_url = 7;
int32 limit_check_interval = 8; // seconds, default 30
int32 limit_refresh_interval = 9; // seconds, default 60
// Limit enforcer configuration (sent from panel)
int32 node_id = 6;
string panel_api_url = 7;
int32 limit_check_interval = 8; // seconds; 0 means "use default" (e.g., 30)
int32 limit_refresh_interval = 9; // seconds; 0 means "use default" (e.g., 60)
🤖 Prompt for AI Agents
In `@PasarGuardNodeBridge/common/service.proto` around lines 26 - 31, The proto
comments saying "default 30/60" are misleading because proto3 scalars decode to
zero; update handling for the fields limit_check_interval and
limit_refresh_interval so zero values don't become 0-second intervals: either
change the proto to use optional or wrapper types (e.g.,
google.protobuf.Int32Value) for limit_check_interval and limit_refresh_interval
so presence can be detected, or keep scalars but add normalization logic in the
node/panel code that reads node_id, panel_api_url, limit_check_interval, and
limit_refresh_interval and replaces 0 with the intended defaults (30 and 60)
before using them.

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