Use localhost for default unix domain socket authority (#445)

This commit is contained in:
Kristopher Wuollett 2024-01-30 10:38:15 -06:00 committed by GitHub
parent 252b57fd45
commit 149a93e0ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 5 deletions

View File

@ -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.
@ -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 != "" {
@ -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...)