Refactor rate limiting applied to network connections #122
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.
This pull request refactors how rate limiting is applied to network connections throughout the codebase. The previous custom
RateConnwrapper 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:
RateConntype and its associated methods fromdaze.go, eliminating a bespoke implementation for rate limiting connections.RateConnin server and client code (protocol/ashe/engine.go,protocol/baboon/engine.go,protocol/czar/engine.go,protocol/dahlia/engine.go) with the standardReadWriteCloserstruct, which now utilizesio.TeeReaderandio.MultiWritercombined withrate.NewLimitsWriterfor rate limiting. [1] [2] [3] [4] [5]Code Consistency and Simplification:
ReadWriteCloserto 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.