diff --git a/app/controls.go b/app/controls.go index 2548651af3..1153594229 100644 --- a/app/controls.go +++ b/app/controls.go @@ -31,7 +31,6 @@ func handleControl(cr ControlRouter) CtxHandlerFunc { control = vars["control"] ) result, err := cr.Handle(ctx, probeID, xfer.Request{ - AppID: UniqueID, NodeID: nodeID, Control: control, }) diff --git a/common/xfer/controls.go b/common/xfer/controls.go index 3bb9c711ac..49a0f35add 100644 --- a/common/xfer/controls.go +++ b/common/xfer/controls.go @@ -11,7 +11,7 @@ var ErrInvalidMessage = fmt.Errorf("Invalid Message") // Request is the UI -> App -> Probe message type for control RPCs type Request struct { - AppID string + AppID string // filled in by the probe on receiving this request NodeID string Control string } diff --git a/probe/appclient/app_client.go b/probe/appclient/app_client.go index 8d8409f0aa..c2fec8b2c0 100644 --- a/probe/appclient/app_client.go +++ b/probe/appclient/app_client.go @@ -41,6 +41,7 @@ type appClient struct { target string client http.Client wsDialer websocket.Dialer + appID string // Track all the background goroutines, ensure they all stop backgroundWait sync.WaitGroup @@ -150,7 +151,11 @@ func (c *appClient) Details() (xfer.Details, error) { return result, err } defer resp.Body.Close() - return result, codec.NewDecoder(resp.Body, &codec.JsonHandle{}).Decode(&result) + if err := codec.NewDecoder(resp.Body, &codec.JsonHandle{}).Decode(&result); err != nil { + return result, err + } + c.appID = result.ID + return result, nil } func (c *appClient) doWithBackoff(msg string, f func() (bool, error)) { @@ -194,9 +199,16 @@ func (c *appClient) controlConnection() (bool, error) { } defer conn.Close() + doControl := func(req xfer.Request) xfer.Response { + req.AppID = c.appID + var res xfer.Response + c.control.Handle(req, &res) + return res + } + codec := xfer.NewJSONWebsocketCodec(conn) server := rpc.NewServer() - if err := server.RegisterName("control", c.control); err != nil { + if err := server.RegisterName("control", xfer.ControlHandlerFunc(doControl)); err != nil { return false, err } diff --git a/tools/lint b/tools/lint index 22db070c0f..db4cd00be4 100755 --- a/tools/lint +++ b/tools/lint @@ -35,7 +35,7 @@ function spell_check { filename="$1" local lint_result=0 - if grep -iH --color=always 'psueod\|availible' "${filename}"; then + if grep -iH --color=always 'psueod\|availible\|reciept' "${filename}"; then echo "${filename}: spelling mistake" lint_result=1 fi