Skip to content

Commit

Permalink
Added localhost to net.Listen() calls to avoid macOS firewall dialog. (
Browse files Browse the repository at this point in the history
  • Loading branch information
meling authored and menghanl committed Sep 26, 2017
1 parent d555c82 commit c67cd63
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Documentation/grpc-auth-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ creds, err := credentials.NewServerTLSFromFile(certFile, keyFile)
if err != nil {
log.Fatalf("Failed to generate credentials %v", err)
}
lis, err := net.Listen("tcp", ":0")
lis, err := net.Listen("tcp", "localhost:0")
server := grpc.NewServer(grpc.Creds(creds))
...
server.Serve(lis)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func main() {
flag.Parse()
grpc.EnableTracing = *trace
go func() {
lis, err := net.Listen("tcp", ":0")
lis, err := net.Listen("tcp", "localhost:0")
if err != nil {
grpclog.Fatalf("Failed to listen: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/latency/latency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func TestListenerAndDialer(t *testing.T) {
}

// Create a real listener and wrap it.
l, err := net.Listen("tcp", ":0")
l, err := net.Listen("tcp", "localhost:0")
if err != nil {
t.Fatalf("Unexpected error creating listener: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var (
func main() {
flag.Parse()
go func() {
lis, err := net.Listen("tcp", ":0")
lis, err := net.Listen("tcp", "localhost:0")
if err != nil {
grpclog.Fatalf("Failed to listen: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func main() {
grpc.EnableTracing = false

flag.Parse()
lis, err := net.Listen("tcp", ":"+strconv.Itoa(*driverPort))
lis, err := net.Listen("tcp", "localhost:"+strconv.Itoa(*driverPort))
if err != nil {
grpclog.Fatalf("failed to listen: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/helloworld/greeter_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
)

const (
port = ":50051"
port = "50051"
)

// server is used to implement helloworld.GreeterServer.
Expand All @@ -43,7 +43,7 @@ func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloRe
}

func main() {
lis, err := net.Listen("tcp", port)
lis, err := net.Listen("tcp", "localhost:"+port)
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion interop/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var (
func main() {
flag.Parse()
p := strconv.Itoa(*port)
lis, err := net.Listen("tcp", ":"+p)
lis, err := net.Listen("tcp", "localhost:"+p)
if err != nil {
grpclog.Fatalf("failed to listen: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion stress/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (s *server) createGauge(name string) *gauge {
}

func startServer(server *server, port int) {
lis, err := net.Listen("tcp", ":"+strconv.Itoa(port))
lis, err := net.Listen("tcp", "localhost:"+strconv.Itoa(port))
if err != nil {
grpclog.Fatalf("failed to listen: %v", err)
}
Expand Down

0 comments on commit c67cd63

Please sign in to comment.