mirror of
https://github.com/openziti/zrok.git
synced 2024-11-22 08:03:49 +01:00
no target for socks backend (#558)
This commit is contained in:
parent
6440685b25
commit
3afbb6dc9a
@ -31,9 +31,9 @@ type reserveCommand struct {
|
||||
|
||||
func newReserveCommand() *reserveCommand {
|
||||
cmd := &cobra.Command{
|
||||
Use: "reserve <public|private> <target>",
|
||||
Use: "reserve <public|private> [<target>]",
|
||||
Short: "Create a reserved share",
|
||||
Args: cobra.ExactArgs(2),
|
||||
Args: cobra.RangeArgs(1, 2),
|
||||
}
|
||||
command := &reserveCommand{cmd: cmd}
|
||||
cmd.Flags().StringVarP(&command.uniqueName, "unique-name", "n", "", "A unique name for the reserved share (defaults to generated identifier)")
|
||||
@ -66,6 +66,9 @@ func (cmd *reserveCommand) run(_ *cobra.Command, args []string) {
|
||||
var target string
|
||||
switch cmd.backendMode {
|
||||
case "proxy":
|
||||
if len(args) != 2 {
|
||||
tui.Error("the 'proxy' backend mode expects a <target>", nil)
|
||||
}
|
||||
v, err := parseUrl(args[1])
|
||||
if err != nil {
|
||||
tui.Error("invalid target endpoint URL", err)
|
||||
@ -73,22 +76,39 @@ func (cmd *reserveCommand) run(_ *cobra.Command, args []string) {
|
||||
target = v
|
||||
|
||||
case "web":
|
||||
if len(args) != 2 {
|
||||
tui.Error("the 'web' backend mode expects a <target>", nil)
|
||||
}
|
||||
target = args[1]
|
||||
|
||||
case "tcpTunnel":
|
||||
if len(args) != 2 {
|
||||
tui.Error("the 'tcpTunnel' backend mode expects a <target>", nil)
|
||||
}
|
||||
target = args[1]
|
||||
|
||||
case "udpTunnel":
|
||||
if len(args) != 2 {
|
||||
tui.Error("the 'udpTunnel' backend mode expects a <target>", nil)
|
||||
}
|
||||
target = args[1]
|
||||
|
||||
case "caddy":
|
||||
if len(args) != 2 {
|
||||
tui.Error("the 'caddy' backend mode expects a <target>", nil)
|
||||
}
|
||||
target = args[1]
|
||||
|
||||
case "drive":
|
||||
if len(args) != 2 {
|
||||
tui.Error("the 'drive' backend mode expects a <target>", nil)
|
||||
}
|
||||
target = args[1]
|
||||
|
||||
case "socks":
|
||||
target = ""
|
||||
if len(args) != 1 {
|
||||
tui.Error("the 'socks' backend mode does not expect <target>", nil)
|
||||
}
|
||||
|
||||
default:
|
||||
tui.Error(fmt.Sprintf("invalid backend mode '%v'; expected {proxy, web, tcpTunnel, udpTunnel, caddy, drive, socks}", cmd.backendMode), nil)
|
||||
|
@ -34,9 +34,9 @@ type sharePrivateCommand struct {
|
||||
|
||||
func newSharePrivateCommand() *sharePrivateCommand {
|
||||
cmd := &cobra.Command{
|
||||
Use: "private <target>",
|
||||
Use: "private [<target>]",
|
||||
Short: "Share a target resource privately",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Args: cobra.RangeArgs(0, 1),
|
||||
}
|
||||
command := &sharePrivateCommand{cmd: cmd}
|
||||
cmd.Flags().StringArrayVar(&command.basicAuth, "basic-auth", []string{}, "Basic authentication users (<username:password>,...")
|
||||
@ -52,6 +52,9 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
|
||||
|
||||
switch cmd.backendMode {
|
||||
case "proxy":
|
||||
if len(args) != 1 {
|
||||
tui.Error("the 'proxy' backend mode expects a <target>", nil)
|
||||
}
|
||||
v, err := parseUrl(args[0])
|
||||
if err != nil {
|
||||
if !panicInstead {
|
||||
@ -62,23 +65,40 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
|
||||
target = v
|
||||
|
||||
case "web":
|
||||
if len(args) != 1 {
|
||||
tui.Error("the 'web' backend mode expects a <target>", nil)
|
||||
}
|
||||
target = args[0]
|
||||
|
||||
case "tcpTunnel":
|
||||
if len(args) != 1 {
|
||||
tui.Error("the 'tcpTunnel' backend mode expects a <target>", nil)
|
||||
}
|
||||
target = args[0]
|
||||
|
||||
case "udpTunnel":
|
||||
if len(args) != 1 {
|
||||
tui.Error("the 'udpTunnel' backend mode expects a <target>", nil)
|
||||
}
|
||||
target = args[0]
|
||||
|
||||
case "caddy":
|
||||
if len(args) != 1 {
|
||||
tui.Error("the 'caddy' backend mode expects a <target>", nil)
|
||||
}
|
||||
target = args[0]
|
||||
cmd.headless = true
|
||||
|
||||
case "drive":
|
||||
if len(args) != 1 {
|
||||
tui.Error("the 'drive' backend mode expects a <target>", nil)
|
||||
}
|
||||
target = args[0]
|
||||
|
||||
case "socks":
|
||||
target = ""
|
||||
if len(args) != 0 {
|
||||
tui.Error("the 'socks' backend mode does not expect <target>", nil)
|
||||
}
|
||||
|
||||
default:
|
||||
tui.Error(fmt.Sprintf("invalid backend mode '%v'; expected {proxy, web, tcpTunnel, udpTunnel, caddy, drive}", cmd.backendMode), nil)
|
||||
|
Loading…
Reference in New Issue
Block a user