From 879c1de59da2437942684e8a011f9022630dcc78 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 30 May 2022 20:33:54 +0300 Subject: [PATCH] [#1446] services/tree: Use `grpc.WithInsecure` only for nodes without TLS Signed-off-by: Evgenii Stratonikov --- pkg/services/tree/cache.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/services/tree/cache.go b/pkg/services/tree/cache.go index f6a0c4bcb..76d29a00f 100644 --- a/pkg/services/tree/cache.go +++ b/pkg/services/tree/cache.go @@ -2,6 +2,7 @@ package tree import ( "context" + "strings" "sync" "time" @@ -59,10 +60,16 @@ func dialTreeService(ctx context.Context, netmapAddr string) (*grpc.ClientConn, return nil, err } + opts := make([]grpc.DialOption, 1, 2) + opts[0] = grpc.WithBlock() + + // FIXME(@fyrchik): ugly hack #1322 + if !strings.HasPrefix(netAddr.URIAddr(), "grpcs:") { + opts = append(opts, grpc.WithInsecure()) + } + ctx, cancel := context.WithTimeout(ctx, defaultClientConnectTimeout) - cc, err := grpc.DialContext(ctx, netAddr.URIAddr(), - grpc.WithInsecure(), - grpc.WithBlock()) + cc, err := grpc.DialContext(ctx, netAddr.URIAddr(), opts...) cancel() return cc, err