[#1446] services/tree: Use grpc.WithInsecure only for nodes without TLS

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-05-30 20:33:54 +03:00 committed by fyrchik
parent ad3038d16d
commit a2edfec0c3

View file

@ -2,6 +2,7 @@ package tree
import ( import (
"context" "context"
"strings"
"sync" "sync"
"time" "time"
@ -59,10 +60,16 @@ func dialTreeService(ctx context.Context, netmapAddr string) (*grpc.ClientConn,
return nil, err 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) ctx, cancel := context.WithTimeout(ctx, defaultClientConnectTimeout)
cc, err := grpc.DialContext(ctx, netAddr.URIAddr(), cc, err := grpc.DialContext(ctx, netAddr.URIAddr(), opts...)
grpc.WithInsecure(),
grpc.WithBlock())
cancel() cancel()
return cc, err return cc, err