diff --git a/noah/client.go b/noah/client.go index 160f3a425..2c656fab2 100644 --- a/noah/client.go +++ b/noah/client.go @@ -2,10 +2,12 @@ package main import ( "fmt" + "strings" arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1" "github.com/urfave/cli/v2" "google.golang.org/grpc" + "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" ) @@ -52,7 +54,17 @@ func getClientFromState(ctx *cli.Context) (arkv1.ArkServiceClient, func(), error } func getClient(ctx *cli.Context, addr string) (arkv1.ArkServiceClient, func(), error) { - conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials())) + creds := insecure.NewCredentials() + port := 80 + if strings.HasPrefix(addr, "https://") { + addr = strings.TrimPrefix(addr, "https://") + creds = credentials.NewTLS(nil) + port = 443 + } + if !strings.Contains(addr, ":") { + addr = fmt.Sprintf("%s:%d", addr, port) + } + conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(creds)) if err != nil { return nil, nil, err }