From 1ea63c9e71b9fe15e1878101a18ec3aee3a5c195 Mon Sep 17 00:00:00 2001 From: Hein Meling Date: Thu, 31 Aug 2017 10:24:01 -0700 Subject: [PATCH] Fix to avoid annoying firewall dialog on macOS (#1499) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit macOS throws up an annoying firewall dialog with the following question every time you start the route_guide/server: Do you want the application “server” to accept incoming network connections? This simple fix of actually typing out `localhost` seems to fix this problem. --- examples/gotutorial.md | 4 ++-- examples/route_guide/server/server.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gotutorial.md b/examples/gotutorial.md index 5878be74..22d2e2ca 100644 --- a/examples/gotutorial.md +++ b/examples/gotutorial.md @@ -263,7 +263,7 @@ Once we've implemented all our methods, we also need to start up a gRPC server s ```go flag.Parse() -lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *port)) +lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", *port)) if err != nil { log.Fatalf("failed to listen: %v", err) } @@ -274,7 +274,7 @@ grpcServer.Serve(lis) ``` To build and start a server, we: -1. Specify the port we want to use to listen for client requests using `lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *port))`. +1. Specify the port we want to use to listen for client requests using `lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", *port))`. 2. Create an instance of the gRPC server using `grpc.NewServer()`. 3. Register our service implementation with the gRPC server. 4. Call `Serve()` on the server with our port details to do a blocking wait until the process is killed or `Stop()` is called. diff --git a/examples/route_guide/server/server.go b/examples/route_guide/server/server.go index 065f51c9..5d919047 100644 --- a/examples/route_guide/server/server.go +++ b/examples/route_guide/server/server.go @@ -209,7 +209,7 @@ func newServer() *routeGuideServer { func main() { flag.Parse() - lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *port)) + lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", *port)) if err != nil { log.Fatalf("failed to listen: %v", err) }