-
Notifications
You must be signed in to change notification settings - Fork 490
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
config: Add warning if EndpointAddress and NetAddress ports are equal #6006
config: Add warning if EndpointAddress and NetAddress ports are equal #6006
Conversation
Please also rebase on top of master. |
83fa1b9
to
790fae0
Compare
9d2f5c8
to
020e801
Compare
@algorandskiy Refactored the code based on your feedback. Tests are failing, but I don't have insights into why as CircleCI seems to be gated and with no public access. Would you be able to check? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6006 +/- ##
=======================================
Coverage 55.88% 55.88%
=======================================
Files 482 482
Lines 68447 68463 +16
=======================================
+ Hits 38252 38261 +9
- Misses 27594 27607 +13
+ Partials 2601 2595 -6 ☔ View full report in Codecov by Sentry. |
Summary
Log warning if EndpointAddress and NetAddress has identical ports.
This can happen in a scenario where NetAddress is set to listen to port 0.0.0.0:8080, and where no EndpointAddress is defined. In that case NetAddress is set to listen to 127.0.0.1:0 (port 0 being random OS assigned port in a specific range), however the
makeListener
func indaemon/algod/server.go
has logic that sets the port to be port 8080 in case port 0 is provided (https://github.com/algorand/go-algorand/blob/master/daemon/algod/server.go#L256).This will result in the following:
If you are like me this can cause a lot of confusion as paths and service responses now will default to standard 404 messages and payloads.
The proposed change will add a log warning if the two ports matches up.
Reasoning for a warning is that changing existing logic where port 0 implicitly means port 8080 may be a breaking change for anyone depending on the existing behavior, and where in some cases it could be assumed that people find this desirable (even if not following convention of using port 0).
Note that this PR does not change behavior regarding which address to bind to, meaning that a configuration such as the one below will continue to be a fatal error.
Test Plan
"NetAddress": "0.0.0.0:8080",
to config.json. Warning should be logged."EndpointAddress": "0.0.0.0:8080", "NetAddress": "0.0.0.0:8081",
. No warning should be logged."EndpointAddress": "127.0.0.1:8080", "NetAddress": "[::1]:8080",
. Warning should be logged.