Skip to content

Phase 1: Add rate limiting and enhance error types#15

Merged
BitcoinErrorLog merged 1 commit intomainfrom
phase1-security-hardening
Dec 11, 2025
Merged

Phase 1: Add rate limiting and enhance error types#15
BitcoinErrorLog merged 1 commit intomainfrom
phase1-security-hardening

Conversation

@BitcoinErrorLog
Copy link
Owner

Summary

  • Add RateLimiter module with token bucket algorithm for DOS protection on server side
  • Enhance NoiseError with new variants: RateLimited, MaxSessionsExceeded, SessionExpired, ConnectionReset
  • Add helper methods is_retryable() and retry_after_ms() for error recovery logic
  • Export ServerPolicy from lib root for server configuration
  • Fix format string escaping in storage_queue example

Changes

New Files

  • src/rate_limiter.rs: Thread-safe rate limiter with configurable policies (strict, lenient, disabled)

Modified Files

  • src/errors.rs: Added new error codes and variants with FFI-compatible error codes
  • src/lib.rs: Export new rate limiter types and ServerPolicy
  • examples/storage_queue.rs: Fixed unescaped braces in println! format strings

Test plan

  • All rate limiter tests pass (6 tests)
  • Library compiles with cargo check
  • Code formatted with cargo fmt

Phase 1 of production readiness:
- Add RateLimiter with token bucket algorithm for DOS protection
- Add new error variants: RateLimited, MaxSessionsExceeded, SessionExpired, ConnectionReset
- Add is_retryable() and retry_after_ms() helper methods to NoiseError
- Export ServerPolicy from lib.rs
- Fix format string escaping in storage_queue example
@BitcoinErrorLog BitcoinErrorLog merged commit 33f4606 into main Dec 11, 2025
0 of 2 checks passed
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