Enable gops agent for ziti-tunnel
@@ -21,6 +21,7 @@ import (
"github.com/openziti/edge/tunnel/dns"
"github.com/openziti/edge/tunnel/entities"
"github.com/openziti/edge/tunnel/intercept"
+ "github.com/openziti/foundation/agent"
"github.com/openziti/sdk-golang/ziti"
"github.com/openziti/sdk-golang/ziti/config"
"github.com/openziti/ziti/common/enrollment"
@@ -44,6 +45,8 @@ func init() {
root.PersistentFlags().StringP(resolverCfgFlag, "r", "udp://127.0.0.1:53", "Resolver configuration")
root.PersistentFlags().StringVar(&logFormatter, "log-formatter", "", "Specify log formatter [json|pfxlog|text]")
root.PersistentFlags().StringP(dnsSvcIpRangeFlag, "d", "100.64.0.1/10", "cidr to use when assigning IPs to unresolvable intercept hostnames")
+ root.PersistentFlags().BoolVar(&cliAgentEnabled, "cli-agent", true, "Enable/disable CLI Agent (enabled by default)")
+ root.PersistentFlags().StringVar(&cliAgentAddr, "cli-agent-addr", "", "Specify where CLI Agent should list (ex: unix:/tmp/myfile.sock or tcp:127.0.0.1:10001)")
root.AddCommand(enrollment.NewEnrollCommand())
}
@@ -57,6 +60,8 @@ var root = &cobra.Command{
var interceptor intercept.Interceptor
var resolver dns.Resolver
var logFormatter string
+var cliAgentEnabled bool
+var cliAgentAddr string
func Execute() {
if err := root.Execute(); err != nil {
@@ -89,6 +94,12 @@ func rootPreRun(cmd *cobra.Command, _ []string) {
func rootPostRun(cmd *cobra.Command, _ []string) {
log := pfxlog.Logger()
+ if cliAgentEnabled {
+ if err := agent.Listen(agent.Options{Addr: cliAgentAddr}); err != nil {
+ pfxlog.Logger().WithError(err).Error("unable to start CLI agent")
+ }
+ }
+
identityJson := cmd.Flag("identity").Value.String()
zitiCfg, err := config.NewFromFile(identityJson)
if err != nil {
