Skip to content

Commit

Permalink
subordinate mode messaging improvements (#789)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelquigley committed Nov 12, 2024
1 parent 35fc32b commit 94cfba7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions agent/accessPrivate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions cmd/zrok/accessPrivate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/zrok/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 94cfba7

Please sign in to comment.