mirror of
https://github.com/tailscale/tailscale.git
synced 2026-04-04 14:43:42 -04:00
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user