fixed default to grpcs
This commit is contained in:
@@ -107,18 +107,21 @@ func newForceIPv4Dialer(host, port string) func(context.Context, string) (net.Co
|
||||
|
||||
func normalizeGRPCAddress(grpcURL string) (string, bool, error) {
|
||||
target := strings.TrimSpace(grpcURL)
|
||||
useTLS := false
|
||||
if target == "" {
|
||||
return "", false, merrors.InvalidArgument("tronclient: grpc url is required")
|
||||
}
|
||||
if strings.Contains(target, "://") {
|
||||
|
||||
// Default to secure gRPC when no scheme is provided.
|
||||
if !strings.Contains(target, "://") {
|
||||
target = "grpcs://" + target
|
||||
}
|
||||
|
||||
u, err := url.Parse(target)
|
||||
if err != nil {
|
||||
return "", false, merrors.InvalidArgument("tronclient: invalid grpc url")
|
||||
}
|
||||
if u.Scheme == "https" || u.Scheme == "grpcs" {
|
||||
useTLS = true
|
||||
}
|
||||
|
||||
useTLS := u.Scheme == "https" || u.Scheme == "grpcs"
|
||||
host := strings.TrimSpace(u.Host)
|
||||
if host == "" {
|
||||
return "", false, merrors.InvalidArgument("tronclient: grpc url missing host")
|
||||
@@ -126,10 +129,9 @@ func normalizeGRPCAddress(grpcURL string) (string, bool, error) {
|
||||
if useTLS && u.Port() == "" {
|
||||
host = host + ":443"
|
||||
}
|
||||
|
||||
return host, useTLS, nil
|
||||
}
|
||||
return target, useTLS, nil
|
||||
}
|
||||
|
||||
func grpcTokenUnaryInterceptor(token string) grpc.UnaryClientInterceptor {
|
||||
return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
|
||||
Reference in New Issue
Block a user