Run neard
on localhost
instead of 0.0.0.0
to prevent firewall popups on MacOS
#277
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 PR fixes the problem where users were getting firewall popups when running integration tests on MacOS as described in #276.
It turns out this had two causes:
neard
was running on0.0.0.0
instead oflocalhost
.portpicker
library used to acquire free random ports was testing ports by binding to0.0.0.0
.This PR fixes both causes.
The PR changes how
neard
is ran by using the more verboserun_with_options
where we can specify CLI arguments toneard
. We use this to specify the IP address as localhost. Previously only the port numbers were specified andneard
defaulted to running on0.0.0.0
.This PR also removes the
portpicker
library and provides a simple function to pick random port numbers with the OS feature where port number 0 is replaced by the OS with a random unused port. I initially considered contributing a fix to theportpicker
library, but it seems unmaintained, so I thought it was a better choice to remove it from dependencies.There are two differences between the implementation in the PR and the
portpicker
library:portpicker
library also checks if the port returned by the OS is a valid UDP port. The implementation in this PR forgoes that check as I think we only need TCP ports forneard
.portpicker
library tries to acquire a random port by testing random numbers before falling back to requesting a port with port 0 from the OS. It's unclear why it does this. It might be a mechanism in case the OS doesn't support requesting random ports with port 0. All modern UNIX operating systems and Windows should support this, so I don't think we need such a fallback mechanism, but let me know if we do.