'zrok http -s' for 'service mode' (no tui chrome)

This commit is contained in:
Michael Quigley 2022-08-16 13:31:45 -04:00
parent e32bca31b2
commit 2983d16a06
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

View File

@ -28,6 +28,7 @@ func init() {
}
type httpCommand struct {
service bool
basicAuth []string
cmd *cobra.Command
}
@ -39,17 +40,20 @@ func newHttpCommand() *httpCommand {
Args: cobra.ExactArgs(1),
}
command := &httpCommand{cmd: cmd}
cmd.Flags().BoolVarP(&command.service, "service", "s", false, "Disable TUI 'chrome' for service operation")
cmd.Flags().StringArrayVar(&command.basicAuth, "basic-auth", []string{}, "Basic authentication users (<username:password>,...")
cmd.Run = command.run
return command
}
func (self *httpCommand) run(_ *cobra.Command, args []string) {
if !self.service {
if err := ui.Init(); err != nil {
panic(err)
}
defer ui.Close()
tb.SetInputMode(tb.InputEsc)
}
idCfg, err := zrokdir.IdentityConfigFile()
if err != nil {
@ -113,6 +117,7 @@ func (self *httpCommand) run(_ *cobra.Command, args []string) {
}
}()
if !self.service {
ui.Clear()
w, h := ui.TerminalDimensions()
@ -172,6 +177,12 @@ func (self *httpCommand) run(_ *cobra.Command, args []string) {
ui.Render(p, slg)
}
}
} else {
for {
logrus.Infof("access your zrok service: %v", resp.Payload.ProxyEndpoint)
time.Sleep(30 * time.Second)
}
}
}
func cleanupHttp(id string, cfg *http.Config, zrok *rest_client_zrok.Zrok, auth runtime.ClientAuthInfoWriter) {