Skip to content

Commit 79a7787

Browse files
committed
Replace deprecated grpc.Dial with grpc.NewClient
- Update assets/client.go to use grpc.NewClient - Update swap_server_client.go to use grpc.NewClient - Replace grpc.WithInsecure() with insecure.NewCredentials()
1 parent 835809c commit 79a7787

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

assets/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func getClientConn(config *TapdConfig) (*grpc.ClientConn, error) {
306306
}
307307

308308
// Dial the gRPC server.
309-
conn, err := grpc.Dial(config.Host, opts...)
309+
conn, err := grpc.NewClient(config.Host, opts...)
310310
if err != nil {
311311
return nil, err
312312
}

swap_server_client.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"google.golang.org/grpc"
2727
"google.golang.org/grpc/codes"
2828
"google.golang.org/grpc/credentials"
29+
"google.golang.org/grpc/credentials/insecure"
2930
"google.golang.org/grpc/status"
3031
)
3132

@@ -896,7 +897,7 @@ func rpcRouteCancel(details *outCancelDetails) (
896897
// getSwapServerConn returns a connection to the swap server. A non-empty
897898
// proxyAddr indicates that a SOCKS proxy found at the address should be used to
898899
// establish the connection.
899-
func getSwapServerConn(address, proxyAddress string, insecure bool,
900+
func getSwapServerConn(address, proxyAddress string, insec bool,
900901
tlsPath string, interceptor *l402.ClientInterceptor) (*grpc.ClientConn,
901902
error) {
902903

@@ -914,8 +915,11 @@ func getSwapServerConn(address, proxyAddress string, insecure bool,
914915
// using a self-signed certificate or with a certificate signed by a
915916
// public CA.
916917
switch {
917-
case insecure:
918-
opts = append(opts, grpc.WithInsecure())
918+
case insec:
919+
opts = append(opts, grpc.WithTransportCredentials(
920+
insecure.NewCredentials(),
921+
),
922+
)
919923

920924
case tlsPath != "":
921925
// Load the specified TLS certificate and build
@@ -945,7 +949,7 @@ func getSwapServerConn(address, proxyAddress string, insecure bool,
945949
opts = append(opts, grpc.WithContextDialer(torDialer))
946950
}
947951

948-
conn, err := grpc.Dial(address, opts...)
952+
conn, err := grpc.NewClient(address, opts...)
949953
if err != nil {
950954
return nil, fmt.Errorf("unable to connect to RPC server: %v",
951955
err)

0 commit comments

Comments
 (0)