This commit is contained in:
Michael Quigley 2025-06-16 13:28:02 -04:00
parent 21f055e590
commit 49d852ee02
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
4 changed files with 30 additions and 34 deletions

View File

@ -5,6 +5,12 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"net/url"
"os"
"os/signal"
"syscall"
"time"
tea "github.com/charmbracelet/bubbletea" tea "github.com/charmbracelet/bubbletea"
"github.com/go-openapi/runtime" "github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client" httptransport "github.com/go-openapi/runtime/client"
@ -24,11 +30,6 @@ import (
"github.com/openziti/zrok/util" "github.com/openziti/zrok/util"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"net/url"
"os"
"os/signal"
"syscall"
"time"
) )
func init() { func init() {
@ -259,7 +260,7 @@ func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root)
}() }()
} }
c := make(chan os.Signal) c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGKILL, syscall.SIGQUIT) signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGKILL, syscall.SIGQUIT)
go func() { go func() {
<-c <-c
@ -281,16 +282,11 @@ func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root)
if cmd.headless { if cmd.headless {
logrus.Infof("access the zrok share at the following endpoint: %v", endpointUrl.String()) logrus.Infof("access the zrok share at the following endpoint: %v", endpointUrl.String())
for { for req := range requests {
select {
case req := <-requests:
logrus.Infof("%v -> %v %v", req.RemoteAddr, req.Method, req.Path) logrus.Infof("%v -> %v %v", req.RemoteAddr, req.Method, req.Path)
} }
}
} else if cmd.subordinate { } else if cmd.subordinate {
for { for req := range requests {
select {
case req := <-requests:
data := make(map[string]interface{}) data := make(map[string]interface{})
data[subordinate.MessageKey] = "access" data[subordinate.MessageKey] = "access"
data["remote-address"] = req.RemoteAddr data["remote-address"] = req.RemoteAddr
@ -302,7 +298,6 @@ func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root)
} }
fmt.Println(string(jsonData)) fmt.Println(string(jsonData))
} }
}
} else { } else {
mdl := newAccessModel(shrToken, endpointUrl.String()) mdl := newAccessModel(shrToken, endpointUrl.String())
logrus.SetOutput(mdl) logrus.SetOutput(mdl)

View File

@ -1,16 +1,17 @@
package main package main
import ( import (
"os"
"os/signal"
"syscall"
"time"
"github.com/michaelquigley/cf" "github.com/michaelquigley/cf"
"github.com/openziti/zrok/controller/config" "github.com/openziti/zrok/controller/config"
"github.com/openziti/zrok/controller/env" "github.com/openziti/zrok/controller/env"
"github.com/openziti/zrok/controller/metrics" "github.com/openziti/zrok/controller/metrics"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"os/signal"
"syscall"
"time"
) )
func init() { func init() {
@ -47,7 +48,7 @@ func (cmd *bridgeCommand) run(_ *cobra.Command, args []string) {
panic(err) panic(err)
} }
c := make(chan os.Signal) c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM) signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() { go func() {
<-c <-c

View File

@ -136,7 +136,7 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
} }
if !cmd.headless && prg != nil { if !cmd.headless && prg != nil {
prg.Send(fmt.Sprintf("the zrok environment was successfully enabled...")) prg.Send("the zrok environment was successfully enabled...")
prg.Quit() prg.Quit()
} else { } else {
logrus.Infof("the zrok environment was successfully enabled...") logrus.Infof("the zrok environment was successfully enabled...")

View File

@ -2,6 +2,9 @@ package main
import ( import (
"fmt" "fmt"
"os"
"strings"
"github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea" tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss"
@ -11,8 +14,6 @@ import (
"github.com/openziti/zrok/tui" "github.com/openziti/zrok/tui"
"github.com/openziti/zrok/util" "github.com/openziti/zrok/util"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"strings"
) )
func init() { func init() {
@ -87,7 +88,7 @@ func (cmd *inviteCommand) run(_ *cobra.Command, _ []string) {
} }
fmt.Printf("invitation sent to '%v'!\n\n", email) fmt.Printf("invitation sent to '%v'!\n\n", email)
fmt.Println(fmt.Sprintf("%v\n", tui.Attention.Render("*** be sure to check your SPAM folder if you do not receive the invitation email!"))) fmt.Printf("%v\n", tui.Attention.Render("*** be sure to check your SPAM folder if you do not receive the invitation email!"))
} }
} }
@ -104,7 +105,6 @@ type inviteTui struct {
msg string msg string
emailInputs []textinput.Model emailInputs []textinput.Model
tokenInput textinput.Model tokenInput textinput.Model
cursorMode textinput.CursorMode
done bool done bool
invitesOpen bool invitesOpen bool
requireInviteToken bool requireInviteToken bool