From 88107b12876335f7bbb08931b5b659aaa4be3fc7 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 15 Sep 2020 09:54:52 -0700 Subject: [PATCH] control/controlclient: add TS_DEBUG_MAPRESPONSE to dump all MapResponses I'm always adding this by hand during development. Time to check it in. --- control/controlclient/direct.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index 605d65943..aa1f4d985 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -717,6 +717,8 @@ func decode(res *http.Response, v interface{}, serverKey *wgcfg.Key, mkey *wgcfg return decodeMsg(msg, v, serverKey, mkey) } +var dumpMapResponse, _ = strconv.ParseBool(os.Getenv("TS_DEBUG_MAPRESPONSE")) + func (c *Direct) decodeMsg(msg []byte, v interface{}) error { c.mu.Lock() mkey := c.persist.PrivateMachineKey @@ -741,6 +743,11 @@ func (c *Direct) decodeMsg(msg []byte, v interface{}) error { return err } } + if dumpMapResponse { + var buf bytes.Buffer + json.Indent(&buf, b, "", " ") + log.Printf("MapResponse: %s", buf.Bytes()) + } if err := json.Unmarshal(b, v); err != nil { return fmt.Errorf("response: %v", err) }