build stuff
This commit is contained in:
39
cmd/tunnel.go
Normal file
39
cmd/tunnel.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"reichard.io/conduit/client"
|
||||
"reichard.io/conduit/config"
|
||||
)
|
||||
|
||||
var tunnelCmd = &cobra.Command{
|
||||
Use: "tunnel <name> <host:port>",
|
||||
Short: "Create a conduit tunnel",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// Get Client Config
|
||||
cfg, err := config.GetClientConfig(cmd.Flags())
|
||||
if err != nil {
|
||||
log.Fatal("failed to get client config:", err)
|
||||
}
|
||||
|
||||
// Create Tunnel
|
||||
tunnel, err := client.NewTunnel(cfg)
|
||||
if err != nil {
|
||||
log.Fatal("failed to create tunnel:", err)
|
||||
}
|
||||
|
||||
// Start Tunnel
|
||||
log.Infof("creating TCP tunnel: %s -> %s", cfg.TunnelName, cfg.TunnelTarget)
|
||||
if err := tunnel.Start(); err != nil {
|
||||
log.Fatal("failed to start tunnel:", err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
configDefs := config.GetConfigDefs[config.ClientConfig]()
|
||||
for _, d := range configDefs {
|
||||
tunnelCmd.Flags().String(d.Key, d.Default, d.Description)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user