diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index a82637fcd..647bc6c97 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -776,7 +776,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm // return err log.Println("Ping Triggered") c.CustomPing(&resp) - // go answerPing(c.logf, c.httpc, pr) + go answerPing(c.logf, c.httpc, pr) } if resp.KeepAlive { @@ -1235,6 +1235,7 @@ func sleepAsRequested(ctx context.Context, logf logger.Logf, timeoutReset chan<- func (c *Direct) CustomPing(mr *tailcfg.MapResponse) bool { log.Printf("Custom Ping Triggered with %d number of peers\n", len(mr.Peers)) log.Println("Ping Request: ", mr.PingRequest) + log.Println("ALOHA") log.Println("CP PEERLIST : ", mr.Peers, mr.PeersChanged, mr.PeersRemoved, mr.PeerSeenChange) if len(mr.Peers) > 0 { log.Println("Peer data: ", mr.Peers[0].ID) @@ -1244,27 +1245,29 @@ func (c *Direct) CustomPing(mr *tailcfg.MapResponse) bool { start := time.Now() // Run the ping var pingRes *ipnstate.PingResult - - c.pinger.Ping(ip, true, func(res *ipnstate.PingResult) { - log.Println("Callback", res, (res.NodeIP)) - pingRes = res - }) + for i := 1; i <= 10; i++ { + log.Println("Ping attempt ", i) + go c.pinger.Ping(ip, true, func(res *ipnstate.PingResult) { + log.Println("Callback", res, (res.NodeIP)) + pingRes = res + }) + } log.Println("PINGRES", pingRes) duration := time.Since(start) // Send the data to the handler in api.go admin/api/ping log.Printf("Ping operation took %f seconds\n", duration.Seconds()) - pinginfo := bytes.NewBuffer([]byte((fmt.Sprintf("Ping operation took %f seconds\n", duration.Seconds())))) - request, err := http.NewRequest("PUT", mr.PingRequest.URL, pinginfo) - if err != nil { - return false - } - resp, err := c.httpc.Do(request) - if err != nil { - return false - } - body, _ := ioutil.ReadAll(resp.Body) - log.Println("HTTP RESPONSE", resp, string(body)) + // pinginfo := bytes.NewBuffer([]byte((fmt.Sprintf("Ping operation took %f seconds\n", duration.Seconds())))) + // request, err := http.NewRequest("PUT", mr.PingRequest.URL, pinginfo) + // if err != nil { + // return false + // } + // resp, err := c.httpc.Do(request) + // if err != nil { + // return false + // } + // body, _ := ioutil.ReadAll(resp.Body) + // log.Println("HTTP RESPONSE", resp, string(body)) return len(mr.Peers) > 0 } diff --git a/tstest/integration/testcontrol/testcontrol.go b/tstest/integration/testcontrol/testcontrol.go index 94bb6cea7..038e076ab 100644 --- a/tstest/integration/testcontrol/testcontrol.go +++ b/tstest/integration/testcontrol/testcontrol.go @@ -423,10 +423,10 @@ func (s *Server) addPingRequest(res *tailcfg.MapResponse) error { } targetIP := res.Peers[0].AllowedIPs[0].IP() res.PingRequest = &tailcfg.PingRequest{URL: s.BaseURL + "/ping", TestIP: targetIP, Types: "tsmp"} - jsonRes, _ := json.MarshalIndent(res, "", " ") - log.Println("jsonprint", string(jsonRes)) - log.Println("respeers", res.Peers) - log.Println("allnodes", s.AllNodes(), res.Node.AllowedIPs) + // jsonRes, _ := json.MarshalIndent(res, "", " ") + // log.Println("jsonprint", string(jsonRes)) + // log.Println("respeers", res.Peers) + // log.Println("allnodes", s.AllNodes(), res.Node.AllowedIPs) return nil } diff --git a/wgengine/userspace.go b/wgengine/userspace.go index 20af4b887..4239bb75c 100644 --- a/wgengine/userspace.go +++ b/wgengine/userspace.go @@ -308,6 +308,7 @@ func NewUserspaceEngine(logf logger.Logf, conf Config) (_ Engine, reterr error) e.wgLogger = wglog.NewLogger(logf) e.tundev.OnTSMPPongReceived = func(pong packet.TSMPPongReply) { + log.Println("PONGReceived") e.mu.Lock() defer e.mu.Unlock() cb := e.pongCallback[pong.Data]