-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
network: fixes to public address support #5851
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #5851 +/- ##
==========================================
- Coverage 55.95% 55.92% -0.03%
==========================================
Files 477 477
Lines 67346 67355 +9
==========================================
- Hits 37683 37671 -12
- Misses 27117 27131 +14
- Partials 2546 2553 +7 ☔ View full report in Codecov by Sentry. |
1. requestTracker changes: - Remove http.Request.RemoteAddr overwriting in request tracker - Remove http.Request from request tracker - Add a new remoteAddresss() method that returns a most suitable address 2. public addr changes: - no otherPublicAddr outside of requestTracker - new remoteAddresss() method provides most meaningful address for incoming requests Rationale: There is a chain http.Handler's in wsNetwork: request tracker and wsNetwork itself. Tracked request is created/updated in the first ServeHTTP and used to save a pointer to http.Request object. This request object is actually gets copied in mux.ServeHTTP that calls downstream wsNetwork's ServeHTTP making the request non-usable in the main wsNetwork's ServeHTTP so removed. otherPublicAddr is an address reported by a peer via our custom X-Algorand-Location header that the only correct value for wsPeer.rootURL (host:port accepting connections) but cannot be trusted. Unconditionally rewriting it with remoteAddr obtained from a tcp connection is too much and a new remoteAddresss() method attempts to provide the most meaningful trusted value. Fixes algorand#5713
8c3a37f
to
6e2a2fe
Compare
Co-authored-by: Gary <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems better. Just putting in some minor corrections
Co-authored-by: Jason Paulos <[email protected]>
Summary
http.Request.RemoteAddr
overwriting in request trackerhttp.Request
from request trackerremoteAddresss()
method that returns a most suitable addressotherPublicAddr
outside of requestTrackerremoteAddresss()
method provides most meaningful address for incoming requestsRationale:
There is a chain http.Handler's in wsNetwork: request tracker and wsNetwork itself.
Tracked request is created/updated in the first
ServeHTTP
and used to save a pointer tohttp.Request
object.This request object is actually gets copied in
mux.ServeHTTP
that calls downstream wsNetwork'sServeHTTP
makingthe request non-usable in the main wsNetwork's ServeHTTP so removed.
otherPublicAddr
is an address reported by a peer via our customX-Algorand-Location
header that the onlycorrect value for wsPeer.rootURL (host:port accepting connections) but cannot be trusted.
Unconditionally rewriting it with remoteAddr obtained from a tcp connection is too much and a new
remoteAddresss()
method attempts to provide the most meaningful trusted value.Fixes #5713
Test Plan
TestPeering
tests since they relied on a buggyotherPublicAddr
overwriting byremoteAddr
.