Support binding to any port (for testing, 127.0.0.1) for acceptor
bsergean opened this issue · comments
The problem I am trying to solve is getting rid of modal dialogs on macOS about "the application is trying to run a server on port xxxx".
In torrent_start.go we have:
func (t *torrent) startAcceptor() {
if t.acceptor != nil {
return
}
listener, err := net.ListenTCP("tcp4", &net.TCPAddr{Port: t.port})
if err != nil {
t.log.Warningf("cannot listen port %d: %s", t.port, err)
} else {
t.log.Info("Listening peers on tcp://" + listener.Addr().String())
t.port = listener.Addr().(*net.TCPAddr).Port
t.portC <- t.port
t.acceptor = acceptor.New(listener, t.incomingConnC, t.log)
go t.acceptor.Run()
}
}
If we were to pass another argument to TCPAddr we could bind to another host.
Thanks @cenkalti !