loooprpc: 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()
This commit is contained in:
Slyghtning 2025-12-11 15:16:30 +01:00
parent a3db145ced
commit 175b7d601b
No known key found for this signature in database
GPG key ID: F82D456EA023C9BF
10 changed files with 1145 additions and 4309 deletions

View file

@ -26,6 +26,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/status"
)
@ -896,7 +897,7 @@ func rpcRouteCancel(details *outCancelDetails) (
// getSwapServerConn returns a connection to the swap server. A non-empty
// proxyAddr indicates that a SOCKS proxy found at the address should be used to
// establish the connection.
func getSwapServerConn(address, proxyAddress string, insecure bool,
func getSwapServerConn(address, proxyAddress string, skipCertCheck bool,
tlsPath string, interceptor *l402.ClientInterceptor) (*grpc.ClientConn,
error) {
@ -914,8 +915,9 @@ func getSwapServerConn(address, proxyAddress string, insecure bool,
// using a self-signed certificate or with a certificate signed by a
// public CA.
switch {
case insecure:
opts = append(opts, grpc.WithInsecure())
case skipCertCheck:
creds := insecure.NewCredentials()
opts = append(opts, grpc.WithTransportCredentials(creds))
case tlsPath != "":
// Load the specified TLS certificate and build
@ -945,7 +947,7 @@ func getSwapServerConn(address, proxyAddress string, insecure bool,
opts = append(opts, grpc.WithContextDialer(torDialer))
}
conn, err := grpc.Dial(address, opts...)
conn, err := grpc.NewClient(address, opts...)
if err != nil {
return nil, fmt.Errorf("unable to connect to RPC server: %v",
err)