mirror of
https://github.com/openziti/zrok.git
synced 2025-06-21 10:17:51 +02:00
add '--force-local' and '--force-agent' to 'zrok share [public|private|reserved]' and 'zrok access private' (#751)
This commit is contained in:
parent
f1200eef59
commit
b49d70b738
@ -37,6 +37,8 @@ type accessPrivateCommand struct {
|
|||||||
bindAddress string
|
bindAddress string
|
||||||
headless bool
|
headless bool
|
||||||
subordinate bool
|
subordinate bool
|
||||||
|
forceLocal bool
|
||||||
|
forceAgent bool
|
||||||
responseHeaders []string
|
responseHeaders []string
|
||||||
cmd *cobra.Command
|
cmd *cobra.Command
|
||||||
}
|
}
|
||||||
@ -51,6 +53,9 @@ func newAccessPrivateCommand() *accessPrivateCommand {
|
|||||||
cmd.Flags().BoolVar(&command.headless, "headless", false, "Disable TUI and run headless")
|
cmd.Flags().BoolVar(&command.headless, "headless", false, "Disable TUI and run headless")
|
||||||
cmd.Flags().BoolVar(&command.subordinate, "subordinate", false, "Enable subordinate mode")
|
cmd.Flags().BoolVar(&command.subordinate, "subordinate", false, "Enable subordinate mode")
|
||||||
cmd.MarkFlagsMutuallyExclusive("headless", "subordinate")
|
cmd.MarkFlagsMutuallyExclusive("headless", "subordinate")
|
||||||
|
cmd.Flags().BoolVar(&command.forceLocal, "force-local", false, "Skip agent detection and force local mode")
|
||||||
|
cmd.Flags().BoolVar(&command.forceAgent, "force-agent", false, "Skip agent detection and force agent mode")
|
||||||
|
cmd.MarkFlagsMutuallyExclusive("force-local", "force-agent")
|
||||||
cmd.Flags().StringVarP(&command.bindAddress, "bind", "b", "127.0.0.1:9191", "The address to bind the private frontend")
|
cmd.Flags().StringVarP(&command.bindAddress, "bind", "b", "127.0.0.1:9191", "The address to bind the private frontend")
|
||||||
cmd.Flags().StringArrayVar(&command.responseHeaders, "response-header", []string{}, "Add a response header ('key:value')")
|
cmd.Flags().StringArrayVar(&command.responseHeaders, "response-header", []string{}, "Add a response header ('key:value')")
|
||||||
cmd.Run = command.run
|
cmd.Run = command.run
|
||||||
@ -70,12 +75,15 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.subordinate {
|
if cmd.subordinate || cmd.forceLocal {
|
||||||
cmd.accessLocal(args, root)
|
cmd.accessLocal(args, root)
|
||||||
} else {
|
} else {
|
||||||
agent, err := agentClient.IsAgentRunning(root)
|
agent := cmd.forceAgent
|
||||||
if err != nil {
|
if !cmd.forceAgent {
|
||||||
tui.Error("error checking if agent is running", err)
|
agent, err = agentClient.IsAgentRunning(root)
|
||||||
|
if err != nil {
|
||||||
|
tui.Error("error checking if agent is running", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if agent {
|
if agent {
|
||||||
cmd.accessAgent(args, root)
|
cmd.accessAgent(args, root)
|
||||||
|
@ -35,6 +35,8 @@ type sharePrivateCommand struct {
|
|||||||
backendMode string
|
backendMode string
|
||||||
headless bool
|
headless bool
|
||||||
subordinate bool
|
subordinate bool
|
||||||
|
forceLocal bool
|
||||||
|
forceAgent bool
|
||||||
insecure bool
|
insecure bool
|
||||||
closed bool
|
closed bool
|
||||||
accessGrants []string
|
accessGrants []string
|
||||||
@ -52,6 +54,9 @@ func newSharePrivateCommand() *sharePrivateCommand {
|
|||||||
cmd.Flags().BoolVar(&command.headless, "headless", false, "Disable TUI and run headless")
|
cmd.Flags().BoolVar(&command.headless, "headless", false, "Disable TUI and run headless")
|
||||||
cmd.Flags().BoolVar(&command.subordinate, "subordinate", false, "Enable agent mode")
|
cmd.Flags().BoolVar(&command.subordinate, "subordinate", false, "Enable agent mode")
|
||||||
cmd.MarkFlagsMutuallyExclusive("headless", "subordinate")
|
cmd.MarkFlagsMutuallyExclusive("headless", "subordinate")
|
||||||
|
cmd.Flags().BoolVar(&command.forceLocal, "force-local", false, "Skip agent detection and force local mode")
|
||||||
|
cmd.Flags().BoolVar(&command.forceAgent, "force-agent", false, "Skip agent detection and force agent mode")
|
||||||
|
cmd.MarkFlagsMutuallyExclusive("force-local", "force-agent")
|
||||||
cmd.Flags().BoolVar(&command.insecure, "insecure", false, "Enable insecure TLS certificate validation for <target>")
|
cmd.Flags().BoolVar(&command.insecure, "insecure", false, "Enable insecure TLS certificate validation for <target>")
|
||||||
cmd.Flags().BoolVar(&command.closed, "closed", false, "Enable closed permission mode (see --access-grant)")
|
cmd.Flags().BoolVar(&command.closed, "closed", false, "Enable closed permission mode (see --access-grant)")
|
||||||
cmd.Flags().StringArrayVar(&command.accessGrants, "access-grant", []string{}, "zrok accounts that are allowed to access this share (see --closed)")
|
cmd.Flags().StringArrayVar(&command.accessGrants, "access-grant", []string{}, "zrok accounts that are allowed to access this share (see --closed)")
|
||||||
@ -72,12 +77,15 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.subordinate {
|
if cmd.subordinate || cmd.forceLocal {
|
||||||
cmd.shareLocal(args, root)
|
cmd.shareLocal(args, root)
|
||||||
} else {
|
} else {
|
||||||
agent, err := agentClient.IsAgentRunning(root)
|
agent := cmd.forceAgent
|
||||||
if err != nil {
|
if !cmd.forceAgent {
|
||||||
tui.Error("error checking if agent is running", err)
|
agent, err = agentClient.IsAgentRunning(root)
|
||||||
|
if err != nil {
|
||||||
|
tui.Error("error checking if agent is running", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if agent {
|
if agent {
|
||||||
cmd.shareAgent(args, root)
|
cmd.shareAgent(args, root)
|
||||||
|
@ -35,6 +35,8 @@ type sharePublicCommand struct {
|
|||||||
backendMode string
|
backendMode string
|
||||||
headless bool
|
headless bool
|
||||||
subordinate bool
|
subordinate bool
|
||||||
|
forceLocal bool
|
||||||
|
forceAgent bool
|
||||||
insecure bool
|
insecure bool
|
||||||
oauthProvider string
|
oauthProvider string
|
||||||
oauthEmailAddressPatterns []string
|
oauthEmailAddressPatterns []string
|
||||||
@ -61,6 +63,9 @@ func newSharePublicCommand() *sharePublicCommand {
|
|||||||
cmd.Flags().BoolVar(&command.headless, "headless", false, "Disable TUI and run headless")
|
cmd.Flags().BoolVar(&command.headless, "headless", false, "Disable TUI and run headless")
|
||||||
cmd.Flags().BoolVar(&command.subordinate, "subordinate", false, "Enable agent mode")
|
cmd.Flags().BoolVar(&command.subordinate, "subordinate", false, "Enable agent mode")
|
||||||
cmd.MarkFlagsMutuallyExclusive("headless", "subordinate")
|
cmd.MarkFlagsMutuallyExclusive("headless", "subordinate")
|
||||||
|
cmd.Flags().BoolVar(&command.forceLocal, "force-local", false, "Skip agent detection and force local mode")
|
||||||
|
cmd.Flags().BoolVar(&command.forceAgent, "force-agent", false, "Skip agent detection and force agent mode")
|
||||||
|
cmd.MarkFlagsMutuallyExclusive("force-local", "force-agent")
|
||||||
cmd.Flags().BoolVar(&command.insecure, "insecure", false, "Enable insecure TLS certificate validation for <target>")
|
cmd.Flags().BoolVar(&command.insecure, "insecure", false, "Enable insecure TLS certificate validation for <target>")
|
||||||
cmd.Flags().BoolVar(&command.closed, "closed", false, "Enable closed permission mode (see --access-grant)")
|
cmd.Flags().BoolVar(&command.closed, "closed", false, "Enable closed permission mode (see --access-grant)")
|
||||||
cmd.Flags().StringArrayVar(&command.accessGrants, "access-grant", []string{}, "zrok accounts that are allowed to access this share (see --closed)")
|
cmd.Flags().StringArrayVar(&command.accessGrants, "access-grant", []string{}, "zrok accounts that are allowed to access this share (see --closed)")
|
||||||
@ -87,12 +92,15 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) {
|
|||||||
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.subordinate {
|
if cmd.subordinate || cmd.forceLocal {
|
||||||
cmd.shareLocal(args, root)
|
cmd.shareLocal(args, root)
|
||||||
} else {
|
} else {
|
||||||
agent, err := agentClient.IsAgentRunning(root)
|
agent := cmd.forceAgent
|
||||||
if err != nil {
|
if !cmd.forceAgent {
|
||||||
tui.Error("error checking if agent is running", err)
|
agent, err = agentClient.IsAgentRunning(root)
|
||||||
|
if err != nil {
|
||||||
|
tui.Error("error checking if agent is running", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if agent {
|
if agent {
|
||||||
cmd.shareAgent(args, root)
|
cmd.shareAgent(args, root)
|
||||||
|
@ -34,6 +34,8 @@ type shareReservedCommand struct {
|
|||||||
overrideEndpoint string
|
overrideEndpoint string
|
||||||
headless bool
|
headless bool
|
||||||
subordinate bool
|
subordinate bool
|
||||||
|
forceLocal bool
|
||||||
|
forceAgent bool
|
||||||
insecure bool
|
insecure bool
|
||||||
cmd *cobra.Command
|
cmd *cobra.Command
|
||||||
}
|
}
|
||||||
@ -49,6 +51,9 @@ func newShareReservedCommand() *shareReservedCommand {
|
|||||||
cmd.Flags().BoolVar(&command.headless, "headless", false, "Disable TUI and run headless")
|
cmd.Flags().BoolVar(&command.headless, "headless", false, "Disable TUI and run headless")
|
||||||
cmd.Flags().BoolVar(&command.subordinate, "subordinate", false, "Enable agent mode")
|
cmd.Flags().BoolVar(&command.subordinate, "subordinate", false, "Enable agent mode")
|
||||||
cmd.MarkFlagsMutuallyExclusive("headless", "subordinate")
|
cmd.MarkFlagsMutuallyExclusive("headless", "subordinate")
|
||||||
|
cmd.Flags().BoolVar(&command.forceLocal, "force-local", false, "Skip agent detection and force local mode")
|
||||||
|
cmd.Flags().BoolVar(&command.forceAgent, "force-agent", false, "Skip agent detection and force agent mode")
|
||||||
|
cmd.MarkFlagsMutuallyExclusive("force-local", "force-agent")
|
||||||
cmd.Flags().BoolVar(&command.insecure, "insecure", false, "Enable insecure TLS certificate validation")
|
cmd.Flags().BoolVar(&command.insecure, "insecure", false, "Enable insecure TLS certificate validation")
|
||||||
cmd.Run = command.run
|
cmd.Run = command.run
|
||||||
return command
|
return command
|
||||||
@ -67,12 +72,15 @@ func (cmd *shareReservedCommand) run(_ *cobra.Command, args []string) {
|
|||||||
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.subordinate {
|
if cmd.subordinate || cmd.forceLocal {
|
||||||
cmd.shareLocal(args, root)
|
cmd.shareLocal(args, root)
|
||||||
} else {
|
} else {
|
||||||
agent, err := agentClient.IsAgentRunning(root)
|
agent := cmd.forceAgent
|
||||||
if err != nil {
|
if !cmd.forceAgent {
|
||||||
tui.Error("error checking if agent is running", err)
|
agent, err = agentClient.IsAgentRunning(root)
|
||||||
|
if err != nil {
|
||||||
|
tui.Error("error checking if agent is running", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if agent {
|
if agent {
|
||||||
cmd.shareAgent(args, root)
|
cmd.shareAgent(args, root)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user