2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-08-27 19:32:03 +01:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
2019-01-14 21:19:15 +00:00
|
|
|
"github.com/spf13/pflag"
|
2018-08-27 19:32:03 +01:00
|
|
|
"google.golang.org/grpc"
|
2018-10-16 12:43:44 +01:00
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/identity"
|
|
|
|
"storj.io/common/peertls/tlsopts"
|
2020-03-23 19:18:20 +00:00
|
|
|
"storj.io/private/cfgstruct"
|
2020-02-26 20:43:31 +00:00
|
|
|
"storj.io/storj/private/grpctlsopts"
|
2018-08-27 19:32:03 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2019-01-14 21:19:15 +00:00
|
|
|
targetAddr = pflag.String("target", "satellite.staging.storj.io:7777", "address of target")
|
2018-08-27 19:32:03 +01:00
|
|
|
|
2019-01-30 20:47:21 +00:00
|
|
|
identityConfig identity.Config
|
2018-08-27 19:32:03 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2019-04-19 19:17:30 +01:00
|
|
|
cfgstruct.Bind(pflag.CommandLine, &identityConfig, cfgstruct.UseDevDefaults(), cfgstruct.ConfDir("$HOME/.storj/gw"))
|
2018-08-27 19:32:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
ctx := context.Background()
|
2019-01-14 21:19:15 +00:00
|
|
|
pflag.Parse()
|
2018-08-27 19:32:03 +01:00
|
|
|
identity, err := identityConfig.Load()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-08-19 23:10:38 +01:00
|
|
|
clientOptions, err := tlsopts.NewOptions(identity, tlsopts.Config{}, nil)
|
2018-08-27 19:32:03 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-02-11 11:17:32 +00:00
|
|
|
|
2020-02-26 20:43:31 +00:00
|
|
|
dialOption := grpctlsopts.DialUnverifiedIDOption(clientOptions)
|
2019-02-11 11:17:32 +00:00
|
|
|
|
2019-02-26 18:35:16 +00:00
|
|
|
conn, err := grpc.Dial(*targetAddr, dialOption, grpc.WithInsecure())
|
2018-08-27 19:32:03 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
fmt.Println(conn.GetState())
|
|
|
|
err = conn.Invoke(ctx, "NonExistentMethod", nil, nil)
|
|
|
|
if err != nil && err.Error() != `rpc error: code = ResourceExhausted desc = malformed method name: "NonExistentMethod"` {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
fmt.Println(conn.GetState())
|
2018-09-28 19:08:44 +01:00
|
|
|
err = conn.Close()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2018-08-27 19:32:03 +01:00
|
|
|
}
|