Lots of tests listen on 0.0.0.0
Many of the tests in the test suite attempt to bind to a random port on 0.0.0.0, which means anything can make a connection to the server, including external devices.
On Mac, this is very annoying because each invocation triggers a dialog box asking to allow connections to the test binary. I counted about ten or so of these dialog boxes in one run of the test suite.
To track down this issue, edit $GOROOT/src/net/dial.go, and add the following patch to ListenConfig.Listen:
// See func Listen for a description of the network and address
// parameters.
func (lc *ListenConfig) Listen(ctx context.Context, network, address string) (Listener, error) {
+ if address == ":0" {
+ fmt.Println("ListenConfig.Listen", network, address)
+ debug.PrintStack()
+ }
addrs, err := DefaultResolver.resolveAddrList(ctx, "listen", network, address, nil)
Then rerun the tests. This will likely show you which test file is responsible for opening a socket to 0.0.0.0.
Would listening on 127.0.0.1 instead of 0.0.0.0 fix the issue?
Yes - here's an example CL submitting a patch: https://github.com/grafana/loki/pull/10411
Some machines map "localhost" to a different IP than 127.0.0.1 but it's sufficient for most machines to dial this host.
Basically - I'm happy to fix these just wanted some guidance that this is something you'd be interested in reviewing and merging.
Yep, please do open a PR :+1: