Skip to content

Commit

Permalink
Use localhost for default unix domain socket authority (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
kriswuollett authored Jan 30, 2024
1 parent 252b57f commit 149a93e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cmd/grpcurl/grpcurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ var (
value of the ":authority" pseudo-header in the HTTP/2 protocol. When TLS
is used, this will also be used as the server name when verifying the
server's certificate. It defaults to the address that is provided in the
positional arguments.`))
positional arguments, or 'localhost' in the case of a unix domain
socket.`))
userAgent = flags.String("user-agent", "", prettify(`
If set, the specified value will be added to the User-Agent header set
by the grpc-go library.
Expand Down Expand Up @@ -474,6 +475,13 @@ func main() {
if *maxMsgSz > 0 {
opts = append(opts, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(*maxMsgSz)))
}
network := "tcp"
if isUnixSocket != nil && isUnixSocket() {
network = "unix"
if *authority == "" {
*authority = "localhost"
}
}
var creds credentials.TransportCredentials
if *plaintext {
if *authority != "" {
Expand Down Expand Up @@ -538,10 +546,6 @@ func main() {
}
opts = append(opts, grpc.WithUserAgent(grpcurlUA))

network := "tcp"
if isUnixSocket != nil && isUnixSocket() {
network = "unix"
}
blockingDialTiming := dialTiming.Child("BlockingDial")
defer blockingDialTiming.Done()
cc, err := grpcurl.BlockingDial(ctx, network, target, creds, opts...)
Expand Down

0 comments on commit 149a93e

Please sign in to comment.