subordinate mode messaging improvements (#789)

This commit is contained in:
Michael Quigley 2024-11-12 12:51:41 -05:00
parent 35fc32b5f8
commit 94cfba746c
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
3 changed files with 4 additions and 3 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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)
}