mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-23 00:56:20 +00:00
ipn/ipnlocal: add a C2N endpoint for fetching a netmap
For debugging purposes, add a new C2N endpoint returning the current netmap. Optionally, coordination server can send a new "candidate" map response, which the client will generate a separate netmap for. Coordination server can later compare two netmaps, detecting unexpected changes to the client state. Updates tailscale/corp#32095 Signed-off-by: Anton Tolchanov <anton@tailscale.com>
This commit is contained in:
committed by
Anton Tolchanov
parent
394718a4ca
commit
4a04161828
@@ -20,6 +20,7 @@ import (
|
||||
"go4.org/mem"
|
||||
"tailscale.com/control/controlknobs"
|
||||
"tailscale.com/health"
|
||||
"tailscale.com/ipn"
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/tstest"
|
||||
"tailscale.com/tstime"
|
||||
@@ -27,6 +28,7 @@ import (
|
||||
"tailscale.com/types/key"
|
||||
"tailscale.com/types/logger"
|
||||
"tailscale.com/types/netmap"
|
||||
"tailscale.com/types/persist"
|
||||
"tailscale.com/types/ptr"
|
||||
"tailscale.com/util/eventbus/eventbustest"
|
||||
"tailscale.com/util/mak"
|
||||
@@ -1419,3 +1421,27 @@ func TestNetmapDisplayMessageIntegration(t *testing.T) {
|
||||
t.Errorf("unexpected message contents (-want +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNetmapForMapResponseForDebug(t *testing.T) {
|
||||
mr := &tailcfg.MapResponse{
|
||||
Node: &tailcfg.Node{
|
||||
ID: 1,
|
||||
Name: "foo.bar.ts.net.",
|
||||
},
|
||||
Peers: []*tailcfg.Node{
|
||||
{ID: 2, Name: "peer1.bar.ts.net.", HomeDERP: 1},
|
||||
{ID: 3, Name: "peer2.bar.ts.net.", HomeDERP: 1},
|
||||
},
|
||||
}
|
||||
ms := newTestMapSession(t, nil)
|
||||
nm1 := ms.netmapForResponse(mr)
|
||||
|
||||
prefs := &ipn.Prefs{Persist: &persist.Persist{PrivateNodeKey: ms.privateNodeKey}}
|
||||
nm2, err := NetmapFromMapResponseForDebug(t.Context(), prefs.View().Persist(), mr)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(nm1, nm2) {
|
||||
t.Errorf("mismatch\nnm1: %s\nnm2: %s\n", logger.AsJSON(nm1), logger.AsJSON(nm2))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user