Skip to content

Commit

Permalink
internal: fix net.Dial fail without IP (#4037)
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Nov 16, 2020
1 parent 1d01bf9 commit 707e298
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/authority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ func (s) TestColonPortAuthority(t *testing.T) {
authorityMu.Unlock()
// ss.Start dials, but not the ":[port]" target that is being tested here.
// Dial again, with ":[port]" as the target.
cc, err := grpc.Dial(":"+port, grpc.WithInsecure())
//
// Append "localhost" before calling net.Dial, in case net.Dial on certain
// platforms doesn't work well for address without the IP.
cc, err := grpc.Dial(":"+port, grpc.WithInsecure(), grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
return (&net.Dialer{}).DialContext(ctx, "tcp", "localhost"+addr)
}))
if err != nil {
t.Fatalf("grpc.Dial(%q) = %v", ss.target, err)
}
Expand Down

0 comments on commit 707e298

Please sign in to comment.