-
Notifications
You must be signed in to change notification settings - Fork 402
/
main.go
56 lines (46 loc) · 1.24 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package main
import (
"context"
"fmt"
"github.com/spf13/pflag"
"google.golang.org/grpc"
"storj.io/storj/pkg/cfgstruct"
"storj.io/storj/pkg/identity"
"storj.io/storj/pkg/peertls/tlsopts"
)
var (
targetAddr = pflag.String("target", "satellite.staging.storj.io:7777", "address of target")
identityConfig identity.Config
)
func init() {
cfgstruct.Bind(pflag.CommandLine, &identityConfig, cfgstruct.UseDevDefaults(), cfgstruct.ConfDir("$HOME/.storj/gw"))
}
func main() {
ctx := context.Background()
pflag.Parse()
identity, err := identityConfig.Load()
if err != nil {
panic(err)
}
clientOptions, err := tlsopts.NewOptions(identity, tlsopts.Config{}, nil)
if err != nil {
panic(err)
}
dialOption := clientOptions.DialUnverifiedIDOption()
conn, err := grpc.Dial(*targetAddr, dialOption, grpc.WithInsecure())
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())
err = conn.Close()
if err != nil {
fmt.Println(err)
}
}