-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconn-check.go
47 lines (40 loc) · 1.01 KB
/
conn-check.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
package main
import (
"context"
"crypto/tls"
"log"
"os"
"github.com/quic-go/quic-go"
"github.com/quic-go/quic-go/logging"
"github.com/quic-go/quic-go/qlog"
"github.com/spf13/cobra"
)
var connCheckCmd = cobra.Command{
Use: "conn-check",
Short: "Connect and dump qlog trace",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
runConnCheck(context.Background(), args[0])
},
}
func init() {
rootCmd.AddCommand(&connCheckCmd)
}
func runConnCheck(ctx context.Context, dst string) {
quicConfig := &quic.Config{
Tracer: func(ctx context.Context, p logging.Perspective, odcid quic.ConnectionID) *logging.ConnectionTracer {
return qlog.NewConnectionTracer(os.Stdout, p, odcid)
},
}
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{genSolanaCert()},
NextProtos: []string{"solana-tpu"},
InsecureSkipVerify: true,
}
conn, err := quic.DialAddr(ctx, dst, tlsConfig, quicConfig)
if err != nil {
log.Print(err)
return
}
defer conn.CloseWithError(0, "")
}