Listen only on 127.0.0.1

Instead of binding on 0.0.0.0 (which will listen on every interface)
let's only listen on localhost. On windows, this both makes the
connection Just Work and also prevents the Windows Firewall from
blocking the listen (and displaying UI saying it has blocked an
application and asking if the user should allow it)
This commit is contained in:
Matt Ellis 2017-09-21 10:56:45 -07:00
parent 1c2c972d37
commit 25ae463915
3 changed files with 3 additions and 3 deletions

View file

@ -201,7 +201,7 @@ func newResourceMonitor(reschan chan *evalSourceGoal) (*resmon, error) {
return nil, err
}
resmon.addr = fmt.Sprintf("0.0.0.0:%d", port)
resmon.addr = fmt.Sprintf("127.0.0.1:%d", port)
resmon.done = done
return resmon, nil

View file

@ -44,7 +44,7 @@ func newHostServer(host Host, ctx *Context) (*hostServer, error) {
return nil, err
}
engine.addr = fmt.Sprintf("0.0.0.0:%d", port)
engine.addr = fmt.Sprintf("127.0.0.1:%d", port)
engine.done = done
return engine, nil

View file

@ -30,7 +30,7 @@ func IsBenignCloseErr(err error) bool {
// the server is finished, in the case of a successful launch of the RPC server.
func Serve(port int, cancel chan bool, registers []func(*grpc.Server) error) (int, chan error, error) {
// Listen on a TCP port, but let the kernel choose a free port for us.
lis, err := net.Listen("tcp", ":"+strconv.Itoa(port))
lis, err := net.Listen("tcp", "127.0.0.1:"+strconv.Itoa(port))
if err != nil {
return port, nil, errors.Errorf("failed to listen on TCP port ':%v': %v", port, err)
}