mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-12 05:37:32 +00:00
cmd/tailscale: make netcheck use active DERP map, delete static copy
After allowing for custom DERP maps, it's convenient to be able to see their latency in netcheck. This adds a query to the local tailscaled for the current DERPMap. Updates #1264 Signed-off-by: julianknodt <julianknodt@gmail.com>
This commit is contained in:

committed by
Julian Knodt

parent
15677d8a0e
commit
506c2fe8e2
@@ -32,7 +32,6 @@ import (
|
||||
"inet.af/netaddr"
|
||||
"tailscale.com/derp"
|
||||
"tailscale.com/derp/derphttp"
|
||||
"tailscale.com/derp/derpmap"
|
||||
"tailscale.com/ipn/ipnstate"
|
||||
"tailscale.com/net/stun/stuntest"
|
||||
"tailscale.com/net/tstun"
|
||||
@@ -396,7 +395,19 @@ func TestPickDERPFallback(t *testing.T) {
|
||||
tstest.ResourceCheck(t)
|
||||
|
||||
c := newConn()
|
||||
c.derpMap = derpmap.Prod()
|
||||
dm := &tailcfg.DERPMap{
|
||||
Regions: map[int]*tailcfg.DERPRegion{
|
||||
1: &tailcfg.DERPRegion{},
|
||||
2: &tailcfg.DERPRegion{},
|
||||
3: &tailcfg.DERPRegion{},
|
||||
4: &tailcfg.DERPRegion{},
|
||||
5: &tailcfg.DERPRegion{},
|
||||
6: &tailcfg.DERPRegion{},
|
||||
7: &tailcfg.DERPRegion{},
|
||||
8: &tailcfg.DERPRegion{},
|
||||
},
|
||||
}
|
||||
c.derpMap = dm
|
||||
a := c.pickDERPFallback()
|
||||
if a == 0 {
|
||||
t.Fatalf("pickDERPFallback returned 0")
|
||||
@@ -415,7 +426,7 @@ func TestPickDERPFallback(t *testing.T) {
|
||||
got := map[int]int{}
|
||||
for i := 0; i < 50; i++ {
|
||||
c = newConn()
|
||||
c.derpMap = derpmap.Prod()
|
||||
c.derpMap = dm
|
||||
got[c.pickDERPFallback()]++
|
||||
}
|
||||
t.Logf("distribution: %v", got)
|
||||
|
Reference in New Issue
Block a user