conduit/cmd/tunnel.go
Evan Reichard 2e73689762
All checks were successful
continuous-integration/drone/push Build is passing
http vs tcp tunnel
2025-09-22 23:04:15 -04:00

35 lines
763 B
Go

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)
}
tunnel.Start()
},
}
func init() {
configDefs := config.GetConfigDefs[config.ClientConfig]()
for _, d := range configDefs {
tunnelCmd.Flags().String(d.Key, d.Default, d.Description)
}
}