From 940e1c7690dbb4cc7aab741cf4db3a8f8de884fa Mon Sep 17 00:00:00 2001 From: Simeng He Date: Thu, 13 May 2021 15:00:47 -0400 Subject: [PATCH] Proper url style --- control/controlclient/direct.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index 3a194b499..0ef32f591 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -1228,14 +1228,21 @@ func (c *Direct) CustomPing(mr *tailcfg.MapResponse) bool { // Run the ping time.Sleep(10 * time.Millisecond) duration := time.Since(start) - url := "urlplaceholder" + // Send the data to the handler in api.go admin/api/ping + url := "localhost:whatever/admin/api/ping" // Temporary place holder for something we would stream back pingres := &tailcfg.StreamedPingResult{ IP: mr.PingRequest.TestIP, Seconds: duration.Seconds(), } - body, _ := json.Marshal(pingres) - resp, _ := c.httpc.Post(url, "application/json", bytes.NewBuffer(body)) + body, err := json.Marshal(pingres) + if err != nil { + log.Println(err) + } + resp, err := c.httpc.Post(url, "application/json", bytes.NewBuffer(body)) + if err != nil { + log.Println(err) + } defer resp.Body.Close() return len(mr.Peers) > 0 }