Merge pull request 'fixed default to grpcs' (#623) from tron-622 into main
All checks were successful
ci/woodpecker/push/gateway_tron Pipeline was successful

Reviewed-on: #623
This commit was merged in pull request #623.
This commit is contained in:
2026-03-04 00:31:21 +00:00

View File

@@ -107,28 +107,30 @@ 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, "://") {
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
}
host := strings.TrimSpace(u.Host)
if host == "" {
return "", false, merrors.InvalidArgument("tronclient: grpc url missing host")
}
if useTLS && u.Port() == "" {
host = host + ":443"
}
return host, useTLS, nil
// Default to secure gRPC when no scheme is provided.
if !strings.Contains(target, "://") {
target = "grpcs://" + target
}
return target, useTLS, nil
u, err := url.Parse(target)
if err != nil {
return "", false, merrors.InvalidArgument("tronclient: invalid grpc url")
}
useTLS := u.Scheme == "https" || u.Scheme == "grpcs"
host := strings.TrimSpace(u.Host)
if host == "" {
return "", false, merrors.InvalidArgument("tronclient: grpc url missing host")
}
if useTLS && u.Port() == "" {
host = host + ":443"
}
return host, useTLS, nil
}
func grpcTokenUnaryInterceptor(token string) grpc.UnaryClientInterceptor {