Skip to content

Commit 682168b

Browse files
committed
chore(deps): replace coral with latest cobra
1 parent e64fadc commit 682168b

File tree

9 files changed

+45
-749
lines changed

9 files changed

+45
-749
lines changed

go.mod

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ require (
2020
github.com/mitchellh/mapstructure v1.5.0
2121
github.com/mitchellh/pointerstructure v1.2.1
2222
github.com/mr-tron/base58 v1.2.0
23-
github.com/muesli/coral v1.0.0
2423
github.com/nknorg/encrypted-stream v1.0.1
2524
github.com/patrickmn/go-cache v2.1.0+incompatible
2625
github.com/sirupsen/logrus v1.9.0
2726
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
27+
github.com/spf13/cobra v1.6.1
2828
github.com/stretchr/testify v1.8.1
2929
golang.org/x/crypto v0.7.0
3030
golang.org/x/oauth2 v0.6.0
@@ -67,12 +67,10 @@ require (
6767
github.com/vmihailenco/go-tinylfu v0.2.2 // indirect
6868
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
6969
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
70-
golang.org/x/exp v0.0.0-20230304125523-9ff063c70017 // indirect
7170
golang.org/x/net v0.8.0 // indirect
7271
golang.org/x/term v0.6.0 // indirect
7372
golang.org/x/text v0.8.0 // indirect
7473
golang.org/x/time v0.3.0 // indirect
7574
google.golang.org/appengine v1.6.7 // indirect
7675
google.golang.org/protobuf v1.28.1 // indirect
77-
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
7876
)

go.sum

+9-668
Large diffs are not rendered by default.

internal/cmd/authenticate.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import (
44
"fmt"
55
"github.com/jsiebens/brink/internal/client"
66
"github.com/jsiebens/brink/internal/util"
7-
"github.com/muesli/coral"
87
"github.com/sirupsen/logrus"
8+
"github.com/spf13/cobra"
99
"io/ioutil"
1010
)
1111

12-
func authCommand() *coral.Command {
13-
command := &coral.Command{
12+
func authCommand() *cobra.Command {
13+
command := &cobra.Command{
1414
Use: "auth",
1515
Short: "Manage credentials for the Brink Client.",
1616
}
@@ -21,16 +21,16 @@ func authCommand() *coral.Command {
2121
return command
2222
}
2323

24-
func loginCommand() *coral.Command {
25-
command := &coral.Command{
24+
func loginCommand() *cobra.Command {
25+
command := &cobra.Command{
2626
Use: "login",
2727
Short: "Authenticate the Brink Client for a specific Proxy.",
2828
SilenceUsage: true,
2929
}
3030

3131
registerProxyFlags(command)
3232

33-
command.RunE = func(cmd *coral.Command, args []string) error {
33+
command.RunE = func(cmd *cobra.Command, args []string) error {
3434
logrus.SetOutput(ioutil.Discard)
3535

3636
proxyAddr := getString(BrinkProxyAddr, proxyAddrFlag)
@@ -44,16 +44,16 @@ func loginCommand() *coral.Command {
4444
return command
4545
}
4646

47-
func revokeCommand() *coral.Command {
48-
command := &coral.Command{
47+
func revokeCommand() *cobra.Command {
48+
command := &cobra.Command{
4949
Use: "revoke",
5050
Short: "Delete the current token from the local store.",
5151
SilenceUsage: true,
5252
}
5353

5454
registerProxyFlags(command)
5555

56-
command.RunE = func(cmd *coral.Command, args []string) error {
56+
command.RunE = func(cmd *cobra.Command, args []string) error {
5757
proxyAddr := getString(BrinkProxyAddr, proxyAddrFlag)
5858
if proxyAddr == "" {
5959
return fmt.Errorf("required flag --proxy-addr is missing")

internal/cmd/client.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"fmt"
66
"github.com/jsiebens/brink/internal/client"
77
"github.com/jsiebens/brink/internal/util"
8-
"github.com/muesli/coral"
98
"github.com/sirupsen/logrus"
9+
"github.com/spf13/cobra"
1010
"golang.org/x/sys/execabs"
1111
"io/ioutil"
1212
"net"
@@ -22,16 +22,16 @@ var (
2222
showQR bool
2323
)
2424

25-
func registerProxyFlags(command *coral.Command) {
25+
func registerProxyFlags(command *cobra.Command) {
2626
command.Flags().StringVarP(&proxyAddrFlag, "proxy-addr", "r", "", fmt.Sprintf("Addr of the Brink proxy. This can also be specified via the environment variable %s.", BrinkProxyAddr))
2727
command.Flags().BoolVar(&tlsSkipVerify, "tls-skip-verify", false, "Disable verification of TLS certificates, highly discouraged as it decreases the security of data transmissions.")
2828
command.Flags().StringVar(&caFile, "ca-file", "", "Path on the local disk to a single PEM-encoded CA certificate to verify the proxy or server SSL certificate.")
2929
command.Flags().BoolVar(&noBrowser, "no-browser", false, "Disable the usage of a browser, just print the login URL")
3030
command.Flags().BoolVar(&showQR, "qr", false, "Show QR code for login URLs")
3131
}
3232

33-
func connectCommand() *coral.Command {
34-
command := &coral.Command{
33+
func connectCommand() *cobra.Command {
34+
command := &cobra.Command{
3535
Use: "connect",
3636
Short: "Start a tunnel to a proxy for TCP forwarding through which another process can create a connection (eg. SSH, PostgreSQL) to a remote target.",
3737
SilenceUsage: true,
@@ -48,7 +48,7 @@ func connectCommand() *coral.Command {
4848
command.Flags().Uint64VarP(&listenPort, "listen-port", "p", 0, "Port on which the client should bind and listen for connections that should be tunneled.")
4949
command.Flags().BoolVarP(&listenOnStdin, "listen-on-stdin", "W", false, "If true, the standard input and standard output on the client is forward to the target over the tunnel.")
5050

51-
command.RunE = func(cmd *coral.Command, args []string) error {
51+
command.RunE = func(cmd *cobra.Command, args []string) error {
5252
cancelCtx, cancelFunc := context.WithCancel(cmd.Context())
5353
defer cancelFunc()
5454

@@ -93,8 +93,8 @@ func connectCommand() *coral.Command {
9393
return command
9494
}
9595

96-
func sshCommand() *coral.Command {
97-
command := &coral.Command{
96+
func sshCommand() *cobra.Command {
97+
command := &cobra.Command{
9898
Use: "ssh",
9999
Short: "Start a tunnel to a proxy and launches a proxied ssh connection.",
100100
SilenceUsage: true,
@@ -107,7 +107,7 @@ func sshCommand() *coral.Command {
107107
command.Flags().StringVarP(&targetAddrFlag, "target-addr", "t", "", "Addr of the remote target the connections should be tunneled to.")
108108
command.Flags().StringVarP(&username, "username", "u", "", "Specifies the username to pass through to the client")
109109

110-
command.RunE = func(cmd *coral.Command, args []string) error {
110+
command.RunE = func(cmd *cobra.Command, args []string) error {
111111
cancelCtx, cancelFunc := context.WithCancel(cmd.Context())
112112
defer cancelFunc()
113113

internal/cmd/cmd.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package cmd
22

33
import (
4-
"github.com/muesli/coral"
4+
"github.com/spf13/cobra"
55
"os"
66
)
77

@@ -11,7 +11,7 @@ const (
1111
)
1212

1313
func Execute() error {
14-
rootCmd := &coral.Command{
14+
rootCmd := &cobra.Command{
1515
Use: "brink",
1616
}
1717

internal/cmd/keygen.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ package cmd
33
import (
44
"fmt"
55
"github.com/jsiebens/brink/internal/key"
6-
"github.com/muesli/coral"
6+
"github.com/spf13/cobra"
77
)
88

9-
func keygenCommand() *coral.Command {
10-
command := &coral.Command{
9+
func keygenCommand() *cobra.Command {
10+
command := &cobra.Command{
1111
Use: "keygen",
1212
Short: "",
1313
SilenceUsage: true,
1414
}
1515

16-
command.RunE = func(cmd *coral.Command, args []string) error {
16+
command.RunE = func(cmd *cobra.Command, args []string) error {
1717
privateKey, err := key.GeneratePrivateKey()
1818
if err != nil {
1919
return err

internal/cmd/server.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import (
55
"github.com/jsiebens/brink/internal/auth"
66
"github.com/jsiebens/brink/internal/config"
77
"github.com/jsiebens/brink/internal/proxy"
8-
"github.com/muesli/coral"
8+
"github.com/spf13/cobra"
99
)
1010

11-
func serverCommand() *coral.Command {
12-
command := &coral.Command{
11+
func serverCommand() *cobra.Command {
12+
command := &cobra.Command{
1313
Use: "server",
1414
SilenceUsage: true,
1515
}
@@ -20,16 +20,16 @@ func serverCommand() *coral.Command {
2020
return command
2121
}
2222

23-
func serverAuthCommand() *coral.Command {
23+
func serverAuthCommand() *cobra.Command {
2424
return createServerCommand("auth", "Start an auth server with a configuration file.", auth.StartServer)
2525
}
2626

27-
func serverProxyCommand() *coral.Command {
27+
func serverProxyCommand() *cobra.Command {
2828
return createServerCommand("proxy", "Start a proxy server with a configuration file.", proxy.StartServer)
2929
}
3030

31-
func createServerCommand(use, short string, start func(context.Context, *config.Config) error) *coral.Command {
32-
command := &coral.Command{
31+
func createServerCommand(use, short string, start func(context.Context, *config.Config) error) *cobra.Command {
32+
command := &cobra.Command{
3333
Use: use,
3434
Short: short,
3535
SilenceUsage: true,
@@ -39,7 +39,7 @@ func createServerCommand(use, short string, start func(context.Context, *config.
3939

4040
command.Flags().StringVarP(&configFile, "config", "c", "", "Path to the configuration file.")
4141

42-
command.RunE = func(command *coral.Command, args []string) error {
42+
command.RunE = func(command *cobra.Command, args []string) error {
4343
c, err := config.LoadConfig(configFile)
4444
if err != nil {
4545
return err

internal/cmd/version.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ package cmd
33
import (
44
"fmt"
55
"github.com/jsiebens/brink/internal/version"
6-
"github.com/muesli/coral"
6+
"github.com/spf13/cobra"
77
)
88

9-
func versionCommand() *coral.Command {
10-
var command = &coral.Command{
9+
func versionCommand() *cobra.Command {
10+
var command = &cobra.Command{
1111
Use: "version",
1212
Short: "Display version information",
1313
SilenceUsage: true,
1414
}
1515

16-
command.Run = func(cmd *coral.Command, args []string) {
16+
command.Run = func(cmd *cobra.Command, args []string) {
1717
clientVersion, clientRevision := version.GetReleaseInfo()
1818
fmt.Printf(`
1919
Version: %s

internal/util/net.go

-43
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,8 @@ package util
33
import (
44
"io"
55
"net"
6-
"sync"
76
)
87

9-
func NewOneConnListener(c net.Conn, addr net.Addr) net.Listener {
10-
if addr == nil {
11-
addr = dummyAddr("one-conn-listener")
12-
}
13-
return &oneConnListener{
14-
addr: addr,
15-
conn: c,
16-
}
17-
}
18-
19-
type oneConnListener struct {
20-
addr net.Addr
21-
22-
mu sync.Mutex
23-
conn net.Conn
24-
}
25-
26-
func (ln *oneConnListener) Accept() (c net.Conn, err error) {
27-
ln.mu.Lock()
28-
defer ln.mu.Unlock()
29-
c = ln.conn
30-
if c == nil {
31-
err = io.EOF
32-
return
33-
}
34-
err = nil
35-
ln.conn = nil
36-
return
37-
}
38-
39-
func (ln *oneConnListener) Addr() net.Addr { return ln.addr }
40-
41-
func (ln *oneConnListener) Close() error {
42-
ln.Accept() // guarantee future call returns io.EOF
43-
return nil
44-
}
45-
46-
type dummyAddr string
47-
48-
func (a dummyAddr) Network() string { return string(a) }
49-
func (a dummyAddr) String() string { return string(a) }
50-
518
func NewAltReadWriteCloserConn(rwc io.ReadWriteCloser, c net.Conn) net.Conn {
529
return wrappedConn{c, rwc}
5310
}

0 commit comments

Comments
 (0)