Fix deprecations
This commit is contained in:
parent
67e2a30b16
commit
f5fc59324a
|
|
@ -438,9 +438,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if overrideName != "" {
|
if overrideName != "" {
|
||||||
if err := creds.OverrideServerName(overrideName); err != nil {
|
opts = append(opts, grpc.WithAuthority(overrideName))
|
||||||
fail(err, "Failed to override server name as %q", overrideName)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if *authority != "" {
|
} else if *authority != "" {
|
||||||
opts = append(opts, grpc.WithAuthority(*authority))
|
opts = append(opts, grpc.WithAuthority(*authority))
|
||||||
|
|
|
||||||
13
grpcurl.go
13
grpcurl.go
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"github.com/jhump/protoreflect/dynamic"
|
"github.com/jhump/protoreflect/dynamic"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
protov2 "google.golang.org/protobuf/proto"
|
protov2 "google.golang.org/protobuf/proto"
|
||||||
"google.golang.org/protobuf/types/descriptorpb"
|
"google.golang.org/protobuf/types/descriptorpb"
|
||||||
|
|
@ -632,11 +633,11 @@ func BlockingDial(ctx context.Context, network, address string, creds credential
|
||||||
dialer := func(ctx context.Context, address string) (net.Conn, error) {
|
dialer := func(ctx context.Context, address string) (net.Conn, error) {
|
||||||
// NB: We *could* handle the TLS handshake ourselves, in the custom
|
// NB: We *could* handle the TLS handshake ourselves, in the custom
|
||||||
// dialer (instead of customizing both the dialer and the credentials).
|
// dialer (instead of customizing both the dialer and the credentials).
|
||||||
// But that requires using WithInsecure dial option (so that the gRPC
|
// But that requires using insecure.NewCredentials() dial transport
|
||||||
// library doesn't *also* try to do a handshake). And that would mean
|
// option (so that the gRPC library doesn't *also* try to do a
|
||||||
// that the library would send the wrong ":scheme" metaheader to
|
// handshake). And that would mean that the library would send the
|
||||||
// servers: it would send "http" instead of "https" because it is
|
// wrong ":scheme" metaheader to servers: it would send "http" instead
|
||||||
// unaware that TLS is actually in use.
|
// of "https" because it is unaware that TLS is actually in use.
|
||||||
conn, err := (&net.Dialer{}).DialContext(ctx, network, address)
|
conn, err := (&net.Dialer{}).DialContext(ctx, network, address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeResult(err)
|
writeResult(err)
|
||||||
|
|
@ -657,7 +658,7 @@ func BlockingDial(ctx context.Context, network, address string, creds credential
|
||||||
opts = append(opts, grpc.WithBlock(), grpc.WithContextDialer(dialer))
|
opts = append(opts, grpc.WithBlock(), grpc.WithContextDialer(dialer))
|
||||||
|
|
||||||
if creds == nil {
|
if creds == nil {
|
||||||
opts = append(opts, grpc.WithInsecure())
|
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||||
} else {
|
} else {
|
||||||
opts = append(opts, grpc.WithTransportCredentials(creds))
|
opts = append(opts, grpc.WithTransportCredentials(creds))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"github.com/jhump/protoreflect/grpcreflect"
|
"github.com/jhump/protoreflect/grpcreflect"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
"google.golang.org/grpc/reflection"
|
"google.golang.org/grpc/reflection"
|
||||||
reflectpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
|
reflectpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
|
||||||
|
|
@ -77,7 +78,7 @@ func TestMain(m *testing.M) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if ccReflect, err = grpc.DialContext(ctx, fmt.Sprintf("127.0.0.1:%d", portReflect),
|
if ccReflect, err = grpc.DialContext(ctx, fmt.Sprintf("127.0.0.1:%d", portReflect),
|
||||||
grpc.WithInsecure(), grpc.WithBlock()); err != nil {
|
grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer ccReflect.Close()
|
defer ccReflect.Close()
|
||||||
|
|
@ -102,7 +103,7 @@ func TestMain(m *testing.M) {
|
||||||
ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if ccNoReflect, err = grpc.DialContext(ctx, fmt.Sprintf("127.0.0.1:%d", portProtoset),
|
if ccNoReflect, err = grpc.DialContext(ctx, fmt.Sprintf("127.0.0.1:%d", portProtoset),
|
||||||
grpc.WithInsecure(), grpc.WithBlock()); err != nil {
|
grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer ccNoReflect.Close()
|
defer ccNoReflect.Close()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue