mirror of
https://github.com/tailscale/tailscale.git
synced 2026-05-05 20:26:47 +02:00
More tests added and logging
This commit is contained in:
parent
27773080c1
commit
be14720df4
@ -1244,13 +1244,16 @@ func (c *Direct) CustomPing(mr *tailcfg.MapResponse) bool {
|
||||
log.Println("TestIP : ", ip)
|
||||
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
|
||||
|
||||
if res.LatencySeconds > 0.0 {
|
||||
log.Println("Successful PING!")
|
||||
}
|
||||
})
|
||||
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())
|
||||
|
||||
@ -9,6 +9,7 @@ package tstun
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@ -568,8 +569,10 @@ func (t *Wrapper) InjectOutbound(packet []byte) error {
|
||||
}
|
||||
select {
|
||||
case <-t.closed:
|
||||
log.Println("Closed")
|
||||
return ErrClosed
|
||||
case t.outbound <- packet:
|
||||
log.Println("t.outbound <- packet")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -711,7 +711,11 @@ func (s *Server) receivePingInfo(w http.ResponseWriter, r *http.Request) {
|
||||
// panic("Only PUT requests are supported currently")
|
||||
}
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
log.Println("Ping Info Received", r.Body)
|
||||
reqBody, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
panic("Failed to read request body")
|
||||
}
|
||||
log.Println("Ping Info Received", string(reqBody))
|
||||
w.WriteHeader(200)
|
||||
io.WriteString(w, "Ping Streamed Back")
|
||||
io.WriteString(w, "Ping Streamed Back : "+string(reqBody))
|
||||
}
|
||||
|
||||
@ -1172,8 +1172,10 @@ func (e *userspaceEngine) mySelfIPMatchingFamily(dst netaddr.IP) (src netaddr.IP
|
||||
}
|
||||
|
||||
func (e *userspaceEngine) sendTSMPPing(ip netaddr.IP, peer *tailcfg.Node, res *ipnstate.PingResult, cb func(*ipnstate.PingResult)) {
|
||||
log.Println("TSMPcheck")
|
||||
srcIP, err := e.mySelfIPMatchingFamily(ip)
|
||||
if err != nil {
|
||||
log.Println("TSMPcheckerror")
|
||||
res.Err = err.Error()
|
||||
cb(res)
|
||||
return
|
||||
@ -1195,10 +1197,13 @@ func (e *userspaceEngine) sendTSMPPing(ip netaddr.IP, peer *tailcfg.Node, res *i
|
||||
|
||||
var data [8]byte
|
||||
crand.Read(data[:])
|
||||
log.Println("CRAND CHECK")
|
||||
|
||||
expireTimer := time.AfterFunc(10*time.Second, func() {
|
||||
log.Println("CHECKEXPIRE")
|
||||
e.setTSMPPongCallback(data, nil)
|
||||
})
|
||||
log.Println("TIMECHECK")
|
||||
t0 := time.Now()
|
||||
e.setTSMPPongCallback(data, func(pong packet.TSMPPongReply) {
|
||||
expireTimer.Stop()
|
||||
@ -1213,9 +1218,12 @@ func (e *userspaceEngine) sendTSMPPing(ip netaddr.IP, peer *tailcfg.Node, res *i
|
||||
var tsmpPayload [9]byte
|
||||
tsmpPayload[0] = byte(packet.TSMPTypePing)
|
||||
copy(tsmpPayload[1:], data[:])
|
||||
log.Println("PAYLOADCHECK")
|
||||
|
||||
tsmpPing := packet.Generate(iph, tsmpPayload[:])
|
||||
log.Println("PACKETGEN")
|
||||
e.tundev.InjectOutbound(tsmpPing)
|
||||
log.Println("TUNDEVINJECT")
|
||||
}
|
||||
|
||||
func (e *userspaceEngine) setTSMPPongCallback(data [8]byte, cb func(packet.TSMPPongReply)) {
|
||||
@ -1302,6 +1310,7 @@ func (e *userspaceEngine) peerForIP(ip netaddr.IP) (n *tailcfg.Node, err error)
|
||||
for _, a := range p.Addresses {
|
||||
log.Println("paddr", a)
|
||||
if a.IP() == ip && a.IsSingleIP() && tsaddr.IsTailscaleIP(ip) {
|
||||
log.Println("Foundp")
|
||||
return p, nil
|
||||
} else {
|
||||
log.Println("Failure : ", a.IP(), a.IsSingleIP(), tsaddr.IsTailscaleIP(ip))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user