2018-08-27 19:32:03 +01:00
|
|
|
// Copyright (C) 2018 Storj Labs, Inc.
|
|
|
|
// 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"
|
|
|
|
"storj.io/storj/pkg/provider"
|
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
|
|
|
|
|
|
|
identityConfig provider.IdentityConfig
|
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
2018-11-29 18:39:27 +00:00
|
|
|
dialOption, err := identity.DialOption(storj.NodeID{})
|
2018-08-27 19:32:03 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|