From e3559d1c45b4956ed94d793262712a1e67696e46 Mon Sep 17 00:00:00 2001 From: Zijie Lu Date: Tue, 5 May 2020 15:03:18 -0400 Subject: [PATCH] cmd/netcheck: better DERP latency checking output Fixes #206 Signed-off-by: Zijie Lu --- cmd/tailscale/netcheck.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/cmd/tailscale/netcheck.go b/cmd/tailscale/netcheck.go index 00cd4bed6..c58103dce 100644 --- a/cmd/tailscale/netcheck.go +++ b/cmd/tailscale/netcheck.go @@ -51,15 +51,23 @@ func runNetcheck(ctx context.Context, args []string) error { } fmt.Printf("\t* MappingVariesByDestIP: %v\n", report.MappingVariesByDestIP) fmt.Printf("\t* HairPinning: %v\n", report.HairPinning) - fmt.Printf("\t* Nearest DERP: %v (%v)\n", report.PreferredDERP, c.DERP.LocationOfID(report.PreferredDERP)) - fmt.Printf("\t* DERP latency:\n") - var ss []string - for s := range report.DERPLatency { - ss = append(ss, s) - } - sort.Strings(ss) - for _, s := range ss { - fmt.Printf("\t\t- %s = %v\n", s, report.DERPLatency[s]) + + // When DERP latency checking failed, + // magicsock will try to pick the DERP server that + // most of your other nodes are also using + if len(report.DERPLatency) == 0 { + fmt.Printf("\t* Nearest DERP: unknown (no response to latency probes)\n") + } else { + fmt.Printf("\t* Nearest DERP: %v (%v)\n", report.PreferredDERP, c.DERP.LocationOfID(report.PreferredDERP)) + fmt.Printf("\t* DERP latency:\n") + var ss []string + for s := range report.DERPLatency { + ss = append(ss, s) + } + sort.Strings(ss) + for _, s := range ss { + fmt.Printf("\t\t- %s = %v\n", s, report.DERPLatency[s]) + } } return nil }