Skip to content

Conversation

@mohanson
Copy link
Collaborator

@mohanson mohanson commented Sep 9, 2025

This pull request refactors how rate limiting is applied to network connections throughout the codebase. The previous custom RateConn wrapper is removed and replaced with a more idiomatic approach using Go's standard IO interfaces (io.TeeReader, io.MultiWriter) to enforce rate limits on both reading and writing. This change impacts several server and client implementations, simplifying the code and improving maintainability.

Rate Limiting Refactor:

  • Removed the custom RateConn type and its associated methods from daze.go, eliminating a bespoke implementation for rate limiting connections.
  • Replaced all usages of RateConn in server and client code (protocol/ashe/engine.go, protocol/baboon/engine.go, protocol/czar/engine.go, protocol/dahlia/engine.go) with the standard ReadWriteCloser struct, which now utilizes io.TeeReader and io.MultiWriter combined with rate.NewLimitsWriter for rate limiting. [1] [2] [3] [4] [5]

Code Consistency and Simplification:

  • Updated the instantiation of ReadWriteCloser to consistently use pointers (e.g., &ReadWriteCloser{...}) across all affected files for proper interface implementation and resource management. [1] [2]

These changes collectively modernize rate limiting logic and simplify connection handling, making the codebase easier to understand and maintain.

@mohanson mohanson merged commit 0f4fa9d into master Sep 9, 2025
2 checks passed
@mohanson mohanson deleted the update branch September 9, 2025 09:54
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.

2 participants