✨ Add Policy Server for Rate Limiting#68
Merged
0x46616c6b merged 4 commits intomainfrom Feb 22, 2026
Merged
Conversation
ea818be to
8e721ad
Compare
Add Quota struct and GetQuota method to the UserliService interface and Userli implementation. This queries the Userli API for per-hour and per-day sending limits for a given email address, which will be used by the policy server for rate limiting. Co-Authored-By: OpenCode <noreply@opencode.ai>
Implement a per-sender rate limiter using a sliding window approach that tracks message timestamps and enforces per-hour and per-day sending limits. Includes automatic background cleanup of expired entries to prevent memory growth. Co-Authored-By: OpenCode <noreply@opencode.ai>
Implement a Postfix SMTPD policy delegation server that enforces per-sender rate limits based on quotas from the Userli API. The server checks the END-OF-MESSAGE protocol stage, resolves the sender identity (preferring SASL username), fetches quota limits, and uses the sliding window rate limiter to accept or reject. - Add PolicyServer implementing ConnectionHandler interface - Add policy-specific Prometheus metrics (requests, duration, quota) - Add PolicyListenAddr configuration (default :10003) - Wire up rate limiter, policy server, and metrics in main.go - Comprehensive test coverage for all policy scenarios Co-Authored-By: OpenCode <noreply@opencode.ai>
8e721ad to
5fb0c2d
Compare
- Add POLICY_LISTEN_ADDR to README configuration section - Document rate limiting feature with Postfix integration example - Add policy/rate limiting metrics documentation - Expose policy server port in docker-compose.yml - Update copilot-instructions.md with new architecture overview Co-Authored-By: OpenCode <noreply@opencode.ai>
5fb0c2d to
defa23e
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
GetQuotaAPI endpoint to fetch sender quota limits from UserliDetails
The policy server listens on port 10003 (configurable via
POLICY_LISTEN_ADDR) and implements the Postfix SMTPD Policy Delegation Protocol. It:END-OF-MESSAGEprotocol stage requestsCommits
Quotastruct,GetQuotaonUserliServiceinterface + implementationPolicyServerimplementingConnectionHandler, Prometheus metrics, config, main.go wiringDepends on
This PR was generated with the assistance of OpenCode.