-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Merged
GarrettGutierrez1
merged 18 commits into
grpc:master
from
GarrettGutierrez1:unix-resolver
Oct 16, 2020
Merged
Changes from 14 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0dc491a
Implemented unix resolver.
GarrettGutierrez1 558d60e
Merged master
GarrettGutierrez1 89b46ef
unix package comment
GarrettGutierrez1 bb5b61f
GrpcUA -> GRPCUA
GarrettGutierrez1 001f93a
Using unix resolver for all unix cases
GarrettGutierrez1 96d2c3d
Merge branch 'master' into unix-resolver
GarrettGutierrez1 b867c17
Fixed testing
GarrettGutierrez1 e72a226
NetworkType package implemented.
GarrettGutierrez1 1083324
Merge branch 'master' into unix-resolver
GarrettGutierrez1 257880f
newProxyDialer -> proxyDial
GarrettGutierrez1 84bc233
Reworking proxy testing.
GarrettGutierrez1 2a0040f
test commit
GarrettGutierrez1 8fe0f41
Updating commit
GarrettGutierrez1 1aa3123
Bugfix
GarrettGutierrez1 e10f503
unixResolver -> nopResolver
GarrettGutierrez1 05ee2e3
Merge branch 'master' into unix-resolver
GarrettGutierrez1 5ddbc72
Improved comments
GarrettGutierrez1 da5d08c
Merge branch 'master' into unix-resolver
GarrettGutierrez1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* | ||
* Copyright 2020 gRPC authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
// Package unix implements a resolver for unix targets. | ||
package unix | ||
|
||
import ( | ||
"google.golang.org/grpc/internal/transport/networktype" | ||
"google.golang.org/grpc/resolver" | ||
) | ||
|
||
const scheme = "unix" | ||
|
||
type builder struct{} | ||
|
||
func (*builder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) { | ||
cc.UpdateState(resolver.State{Addresses: []resolver.Address{networktype.Set(resolver.Address{Addr: target.Endpoint}, "unix")}}) | ||
return &unixResolver{}, nil | ||
} | ||
|
||
func (*builder) Scheme() string { | ||
return scheme | ||
} | ||
|
||
type unixResolver struct { | ||
GarrettGutierrez1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
func (*unixResolver) ResolveNow(resolver.ResolveNowOptions) {} | ||
|
||
func (*unixResolver) Close() {} | ||
|
||
func init() { | ||
resolver.Register(&builder{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* | ||
* Copyright 2020 gRPC authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
// Package networktype declares the network type to be used in the default | ||
// dailer. Attribute of a resolver.Address. | ||
package networktype | ||
|
||
import ( | ||
"google.golang.org/grpc/resolver" | ||
) | ||
|
||
// keyType is the key to use for storing State in Attributes. | ||
type keyType string | ||
|
||
const key = keyType("grpc.internal.transport.networktype") | ||
|
||
// Set returns a copy of the provided address with attributes containing networkType. | ||
func Set(address resolver.Address, networkType string) resolver.Address { | ||
address.Attributes = address.Attributes.WithValues(key, networkType) | ||
return address | ||
} | ||
|
||
// Get returns the network type in the resolver.Address and true, or "", false | ||
// if not present. | ||
func Get(address resolver.Address) (string, bool) { | ||
v := address.Attributes.Value(key) | ||
if v == nil { | ||
return "", false | ||
} | ||
return v.(string), true | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 asServerName
? @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 fromresolver.Address.ServerName
:grpc-go/internal/transport/http2_client.go
Line 439 in c6cfaba
But the
ClientHandshake
does:grpc-go/internal/transport/http2_client.go
Line 225 in c6cfaba
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.