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
|
|
|
|
2018-08-27 19:32:03 +01:00
|
|
|
"storj.io/storj/pkg/cfgstruct"
|
2019-01-30 20:47:21 +00:00
|
|
|
"storj.io/storj/pkg/identity"
|
2019-02-11 11:17:32 +00:00
|
|
|
"storj.io/storj/pkg/peertls/tlsopts"
|
2018-11-30 13:40:13 +00:00
|
|
|
"storj.io/storj/pkg/storj"
|
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-01-14 21:19:15 +00:00
|
|
|
cfgstruct.Bind(pflag.CommandLine, &identityConfig, 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-02-11 11:17:32 +00:00
|
|
|
clientOptions, err := tlsopts.NewOptions(identity, tlsopts.Config{})
|
2018-08-27 19:32:03 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-02-11 11:17:32 +00:00
|
|
|
|
|
|
|
dialOption := clientOptions.DialOption(storj.NodeID{})
|
|
|
|
|
2018-08-27 19:32:03 +01:00
|
|
|
conn, err := grpc.Dial(*targetAddr, dialOption)
|
|
|
|
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
|
|
|
}
|