From bb506cf01a45fe1f2fb984c79bb0472a821ffcac Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Thu, 5 Jun 2025 14:46:35 -0400 Subject: [PATCH] disable the agent console (#976) --- agent/agent.go | 11 +++++++---- agent/config.go | 2 ++ cmd/zrok/agentStart.go | 9 +++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index d6825cf9..9b747ef7 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -2,6 +2,10 @@ package agent import ( "context" + "net" + "net/http" + "os" + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/openziti/zrok/agent/agentGrpc" "github.com/openziti/zrok/agent/agentUi" @@ -13,9 +17,6 @@ import ( "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "net" - "net/http" - "os" ) type Agent struct { @@ -66,7 +67,9 @@ func (a *Agent) Run() error { a.agentSocket = agentSocket go a.manager() - go a.gateway() + if a.cfg.ConsoleEnabled { + go a.gateway() + } go a.remoteAgent() a.persistRegistry = false diff --git a/agent/config.go b/agent/config.go index e44e37a8..1bb379fb 100644 --- a/agent/config.go +++ b/agent/config.go @@ -4,6 +4,7 @@ type AgentConfig struct { ConsoleAddress string ConsoleStartPort uint16 ConsoleEndPort uint16 + ConsoleEnabled bool } func DefaultConfig() *AgentConfig { @@ -11,5 +12,6 @@ func DefaultConfig() *AgentConfig { ConsoleAddress: "127.0.0.1", ConsoleStartPort: 8080, ConsoleEndPort: 8181, + ConsoleEnabled: true, } } diff --git a/cmd/zrok/agentStart.go b/cmd/zrok/agentStart.go index 965199f3..0df78286 100644 --- a/cmd/zrok/agentStart.go +++ b/cmd/zrok/agentStart.go @@ -1,13 +1,14 @@ package main import ( + "os" + "os/signal" + "syscall" + "github.com/openziti/zrok/agent" "github.com/openziti/zrok/environment" "github.com/openziti/zrok/tui" "github.com/spf13/cobra" - "os" - "os/signal" - "syscall" ) func init() { @@ -54,7 +55,7 @@ func (cmd *agentStartCommand) run(_ *cobra.Command, _ []string) { tui.Error("error creating agent", err) } - c := make(chan os.Signal) + c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM) go func() { <-c