From 94cfba746c84b769566beed3bb9ac41ff3d34423 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Tue, 12 Nov 2024 12:51:41 -0500 Subject: [PATCH] subordinate mode messaging improvements (#789) --- agent/accessPrivate.go | 3 +-- cmd/zrok/accessPrivate.go | 2 ++ cmd/zrok/util.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/agent/accessPrivate.go b/agent/accessPrivate.go index 2107f2df..2a9298cf 100644 --- a/agent/accessPrivate.go +++ b/agent/accessPrivate.go @@ -47,13 +47,12 @@ func (i *agentGrpcImpl) AccessPrivate(_ context.Context, req *agentGrpc.AccessPr return nil, err } - go acc.monitor() <-acc.bootComplete if acc.bootErr == nil { + go acc.monitor() i.agent.addAccess <- acc return &agentGrpc.AccessPrivateResponse{FrontendToken: acc.frontendToken}, nil } - return nil, acc.bootErr } diff --git a/cmd/zrok/accessPrivate.go b/cmd/zrok/accessPrivate.go index 4b45be38..b940026d 100644 --- a/cmd/zrok/accessPrivate.go +++ b/cmd/zrok/accessPrivate.go @@ -244,6 +244,7 @@ func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root) if cmd.subordinate { data := make(map[string]interface{}) + data["message"] = "boot" data["frontend_token"] = accessResp.Payload.FrontendToken data["bind_address"] = bindAddress jsonData, err := json.Marshal(data) @@ -266,6 +267,7 @@ func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root) select { case req := <-requests: data := make(map[string]interface{}) + data["message"] = "access" data["remote-address"] = req.RemoteAddr data["method"] = req.Method data["path"] = req.Path diff --git a/cmd/zrok/util.go b/cmd/zrok/util.go index 912a1658..e4adfd32 100644 --- a/cmd/zrok/util.go +++ b/cmd/zrok/util.go @@ -47,6 +47,6 @@ func parseUrl(in string) (string, error) { } func subordinateError(err error) { - fmt.Printf("{ \"error\": \"%v\" }\n", err.Error()) + fmt.Printf("{ \"message\": \"error\", \"error\": \"%v\" }\n", err.Error()) os.Exit(1) }