-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client: implement support for "unix" resolver scheme #3890
client: implement support for "unix" resolver scheme #3890
Conversation
@@ -268,7 +257,7 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn * | |||
cc.authority = creds.Info().ServerName | |||
} else if cc.dopts.insecure && cc.dopts.authority != "" { | |||
cc.authority = cc.dopts.authority | |||
} else if unixScheme { | |||
} else if strings.HasPrefix(cc.target, "unix:") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to come from the resolver (with resolver.Address
- is this the same as ServerName
? @menghanl?). It can be done in a follow-up change but this is not what we want to be doing, ideally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually don't do that.
The :authority
header doesn't come from resolver.Address.ServerName
:
grpc-go/internal/transport/http2_client.go
Line 439 in c6cfaba
headerFields = append(headerFields, hpack.HeaderField{Name: ":authority", Value: callHdr.Host}) |
But the ClientHandshake
does:
grpc-go/internal/transport/http2_client.go
Line 225 in c6cfaba
conn, authInfo, err = transportCreds.ClientHandshake(connectCtx, addr.ServerName, conn) |
All the authority thing needs a cleanup..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is what I thought and what I was worried about. The resolver needs a way to set the authority for addresses. I think ServerName
is the right way to do that -- WDYT? Do we want a different handshaker name from authority header value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they should be the same. For security reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed; I think we can consider it a bug that we are not using the address's ServerName for the authority header. But this can be done in a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo the one minor naming thing.
Please make a follow-up PR that sets resolver.Address.ServerName
to "localhost"
in the unix resolver and removes the special-casing for "unix"
in Dial
to set authority
.
@@ -268,7 +257,7 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn * | |||
cc.authority = creds.Info().ServerName | |||
} else if cc.dopts.insecure && cc.dopts.authority != "" { | |||
cc.authority = cc.dopts.authority | |||
} else if unixScheme { | |||
} else if strings.HasPrefix(cc.target, "unix:") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually don't do that.
The :authority
header doesn't come from resolver.Address.ServerName
:
grpc-go/internal/transport/http2_client.go
Line 439 in c6cfaba
headerFields = append(headerFields, hpack.HeaderField{Name: ":authority", Value: callHdr.Host}) |
But the ClientHandshake
does:
grpc-go/internal/transport/http2_client.go
Line 225 in c6cfaba
conn, authInfo, err = transportCreds.ClientHandshake(connectCtx, addr.ServerName, conn) |
All the authority thing needs a cleanup..
Implemented unix resolver. Fixes #2806 .