This commit is contained in:
Simeng He 2021-05-25 13:00:32 -04:00
parent f925d09b83
commit 6725596a0a
5 changed files with 9 additions and 4 deletions

View File

@ -64,6 +64,7 @@ var pingArgs struct {
}
func runPing(ctx context.Context, args []string) error {
fmt.Println("runPing")
c, bc, ctx, cancel := connect(ctx)
defer cancel()

View File

@ -874,8 +874,8 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm
c.expiry = &nm.Expiry
c.mu.Unlock()
log.Println("MAPRESPONSE: ", resp.Node)
c.logf("MAPRESPONSE: %v", resp.Node)
// log.Println("MAPRESPONSE: ", resp.Node)
// c.logf("MAPRESPONSE: %v", resp.Node)
cb(nm)
}
if ctx.Err() != nil {

View File

@ -14,6 +14,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"log"
"inet.af/netaddr"
"tailscale.com/net/flowtrack"
@ -232,6 +233,7 @@ type TSMPPongReply struct {
// AsTSMPPong returns pp as a TSMPPongReply and whether it is one.
// The pong.IPHeader field is not populated.
func (pp *Parsed) AsTSMPPong() (pong TSMPPongReply, ok bool) {
log.Println("TSMPPONG")
if pp.IPProto != ipproto.TSMP {
return
}

View File

@ -825,6 +825,7 @@ func (c *Conn) LastRecvActivityOfDisco(dk tailcfg.DiscoKey) time.Time {
// Ping handles a "tailscale ping" CLI query.
func (c *Conn) Ping(peer *tailcfg.Node, res *ipnstate.PingResult, cb func(*ipnstate.PingResult)) {
log.Println("CLIPING")
c.mu.Lock()
defer c.mu.Unlock()
if c.privateKey.IsZero() {

View File

@ -1208,6 +1208,7 @@ func (e *userspaceEngine) sendTSMPPing(ip netaddr.IP, peer *tailcfg.Node, res *i
log.Println("TIMECHECK")
t0 := time.Now()
e.setTSMPPongCallback(data, func(pong packet.TSMPPongReply) {
log.Println("Pong callback")
expireTimer.Stop()
d := time.Since(t0)
res.LatencySeconds = d.Seconds()
@ -1224,7 +1225,7 @@ func (e *userspaceEngine) sendTSMPPing(ip netaddr.IP, peer *tailcfg.Node, res *i
log.Println("PAYLOADCHECK")
tsmpPing := packet.Generate(iph, tsmpPayload[:])
log.Println("PACKETGEN", string(tsmpPing), *res)
log.Println("PACKETGEN", string(tsmpPing), *res, res.LatencySeconds)
e.tundev.InjectOutbound(tsmpPing)
log.Println("TUNDEVINJECT")
}
@ -1309,7 +1310,7 @@ func (e *userspaceEngine) peerForIP(ip netaddr.IP) (n *tailcfg.Node, err error)
// Check for exact matches before looking for subnet matches.
var bestInNMPrefix netaddr.IPPrefix
var bestInNM *tailcfg.Node
log.Println("Scan starting : ", nm.Peers, len(nm.Peers), nm.Addresses)
log.Println("Scan starting : ", len(nm.Peers), nm.Addresses)
for _, p := range nm.Peers {
log.Println("peerp", p.Addresses, p.AllowedIPs, p.ID)
for _, a := range p.Addresses {