Skip to content
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

Restore Unix socket support #498

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions cmd/grpcurl/grpcurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ func main() {
if *format != "json" && *format != "text" {
fail(nil, "The -format option must be 'json' or 'text'.")
}
if isUnixSocket != nil && isUnixSocket() {
fail(nil, "The -unix option is deprecated, please use unix://{path} as the address instead.")
}
zhyuri marked this conversation as resolved.
Show resolved Hide resolved
if *emitDefaults && *format != "json" {
warn("The -emit-defaults is only used when using json format.")
}
Expand Down Expand Up @@ -483,13 +486,6 @@ 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 @@ -556,7 +552,7 @@ func main() {

blockingDialTiming := dialTiming.Child("BlockingDial")
defer blockingDialTiming.Done()
cc, err := grpcurl.BlockingDial(ctx, network, target, creds, opts...)
cc, err := grpcurl.BlockingDial(ctx, target, creds, opts...)
if err != nil {
fail(err, "Failed to dial target host %q", target)
}
Expand Down Expand Up @@ -881,8 +877,7 @@ method's request type will be sent.
The address will typically be in the form "host:port" where host can be an IP
address or a hostname and port is a numeric port or service name. If an IPv6
address is given, it must be surrounded by brackets, like "[2001:db8::1]". For
Unix variants, if a -unix=true flag is present, then the address must be the
path to the domain socket.
Unix variants, the address must start with schema "unix://" followed by the path.

Available flags:
`, os.Args[0])
Expand Down
2 changes: 1 addition & 1 deletion grpcurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ func ServerTransportCredentials(cacertFile, serverCertFile, serverKeyFile string
// BlockingDial is a helper method to dial the given address, using optional TLS credentials,
// and blocking until the returned connection is ready. If the given credentials are nil, the
// connection will be insecure (plain-text).
func BlockingDial(ctx context.Context, network, address string, creds credentials.TransportCredentials, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
func BlockingDial(ctx context.Context, address string, creds credentials.TransportCredentials, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
zhyuri marked this conversation as resolved.
Show resolved Hide resolved
if creds == nil {
creds = insecure.NewCredentials()
}
Expand Down
2 changes: 1 addition & 1 deletion tls_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func createTestServerAndClient(serverCreds, clientCreds credentials.TransportCre
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()

cc, err := BlockingDial(ctx, "tcp", fmt.Sprintf("127.0.0.1:%d", port), clientCreds)
cc, err := BlockingDial(ctx, fmt.Sprintf("127.0.0.1:%d", port), clientCreds)
if err != nil {
return e, err
}
Expand Down
Loading