diff --git a/cmd/tailscale/cli/status.go b/cmd/tailscale/cli/status.go index a058a2d3c..139c5f21e 100644 --- a/cmd/tailscale/cli/status.go +++ b/cmd/tailscale/cli/status.go @@ -56,6 +56,7 @@ https://github.com/tailscale/tailscale/blob/main/ipn/ipnstate/ipnstate.go fs.StringVar(&statusArgs.listen, "listen", "127.0.0.1:8384", "listen address for web mode; use port 0 for automatic") fs.BoolVar(&statusArgs.browser, "browser", true, "open a browser in web mode") fs.BoolVar(&statusArgs.header, "header", false, "show column headers in table format") + fs.BoolVar(&statusArgs.verbose, "verbose", false, "show additional details, such as hybrid post-quantum sessions") return fs })(), } @@ -69,10 +70,28 @@ var statusArgs struct { self bool // in CLI mode, show status of local machine peers bool // in CLI mode, show status of peer machines header bool // in CLI mode, show column headers in table format + verbose bool // in CLI mode, show additional details } const mullvadTCD = "mullvad.ts.net." +// protocolLabels maps the protocol of a peer's WireGuard session +// to the label shown for it in the status output. +// A protocol with an empty label is not shown. +var protocolLabels = map[string]string{ + ipnstate.ProtocolWireGuardV1: "", + ipnstate.ProtocolWireGuardV1TSPQHybridV1: "hybrid-pq", +} + +// protocolLabel returns the label for the given protocol, +// or the protocol itself if it is not known to this client. +func protocolLabel(protocol string) string { + if label, ok := protocolLabels[protocol]; ok { + return label + } + return protocol +} + func runStatus(ctx context.Context, args []string) error { if len(args) > 0 { return errors.New("unexpected non-flag arguments to 'tailscale status'") @@ -174,20 +193,24 @@ func runStatus(ctx context.Context, args []string) error { if !ps.Online { offline = "; offline" + lastSeenFmt(ps.LastSeen) } + var protocol string + if label := protocolLabel(ps.Protocol); statusArgs.verbose && label != "" { + protocol = "; " + label + } if !ps.Active { if ps.ExitNode { - f("idle; exit node%s", offline) + f("idle%s; exit node%s", protocol, offline) } else if ps.ExitNodeOption { - f("idle; offers exit node%s", offline) + f("idle%s; offers exit node%s", protocol, offline) } else if anyTraffic { - f("idle%s", offline) + f("idle%s%s", protocol, offline) } else if !ps.Online { f("offline%s", lastSeenFmt(ps.LastSeen)) } else { f("-") } } else { - f("active; ") + f("active%s; ", protocol) if ps.ExitNode { f("exit node; ") } else if ps.ExitNodeOption { diff --git a/cmd/tailscale/cli/status_test.go b/cmd/tailscale/cli/status_test.go new file mode 100644 index 000000000..0569f0c79 --- /dev/null +++ b/cmd/tailscale/cli/status_test.go @@ -0,0 +1,27 @@ +// Copyright (c) Tailscale Inc & contributors +// SPDX-License-Identifier: BSD-3-Clause + +package cli + +import ( + "testing" + + "tailscale.com/ipn/ipnstate" +) + +func TestProtocolLabel(t *testing.T) { + tests := []struct { + protocol string + want string + }{ + {"", ""}, + {ipnstate.ProtocolWireGuardV1, ""}, + {ipnstate.ProtocolWireGuardV1TSPQHybridV1, "hybrid-pq"}, + {"wg-v2", "wg-v2"}, + } + for _, tt := range tests { + if got := protocolLabel(tt.protocol); got != tt.want { + t.Errorf("protocolLabel(%q) = %q, want %q", tt.protocol, got, tt.want) + } + } +} diff --git a/flake.nix b/flake.nix index deced0a4a..c01fde093 100644 --- a/flake.nix +++ b/flake.nix @@ -172,4 +172,4 @@ }); }; } -# nix-direnv cache busting line: sha256-GXIh1xGfH5ixVXUkazObeUCEJq20QoUR4j4LFVPrNrs= +# nix-direnv cache busting line: sha256-m8uqJXw76Y9xB/ruEG922edatOOXkYiwUpoELg5tiOc= diff --git a/flakehashes.json b/flakehashes.json index b66939e5a..eef282584 100644 --- a/flakehashes.json +++ b/flakehashes.json @@ -4,7 +4,7 @@ "sri": "sha256-Qmy06FkeFkjqCo1FLSD9dO7hTvdo/gC2VACJniuiQBU=" }, "vendor": { - "goModSum": "sha256-UPSikeu/TsMzCvDYCF0p4uxBlPHFhTpzQCVB7WANYkk=", - "sri": "sha256-GXIh1xGfH5ixVXUkazObeUCEJq20QoUR4j4LFVPrNrs=" + "goModSum": "sha256-lW4jFMZ8IE6bG94SYEl9Otc1iyHdJvMRVyaLYY66K4Y=", + "sri": "sha256-m8uqJXw76Y9xB/ruEG922edatOOXkYiwUpoELg5tiOc=" } } diff --git a/go.mod b/go.mod index 15700cb26..f7b74550f 100644 --- a/go.mod +++ b/go.mod @@ -126,7 +126,7 @@ require ( github.com/tailscale/ts-gokrazy v0.0.0-20260630224145-b83088f2e52e github.com/tailscale/web-client-prebuilt v0.0.0-20260917222731-e0ed2d0d0fea github.com/tailscale/wf v0.0.0-20240214030419-6fbb0a674ee6 - github.com/tailscale/wireguard-go v0.0.0-20261125191149-d74d4ff62061 + github.com/tailscale/wireguard-go v0.0.0-20261204003109-5d2f71d36889 github.com/tailscale/xnet v0.0.0-20240729143630-8497ac4dab2e github.com/tc-hib/winres v0.3.1 github.com/tcnksm/go-httpstat v0.2.0 diff --git a/go.sum b/go.sum index b8b5dde3b..e1928d6f5 100644 --- a/go.sum +++ b/go.sum @@ -840,8 +840,8 @@ github.com/tailscale/web-client-prebuilt v0.0.0-20260917222731-e0ed2d0d0fea h1:a github.com/tailscale/web-client-prebuilt v0.0.0-20260917222731-e0ed2d0d0fea/go.mod h1:agQPE6y6ldqCOui2gkIh7ZMztTkIQKH049tv8siLuNQ= github.com/tailscale/wf v0.0.0-20240214030419-6fbb0a674ee6 h1:l10Gi6w9jxvinoiq15g8OToDdASBni4CyJOdHY1Hr8M= github.com/tailscale/wf v0.0.0-20240214030419-6fbb0a674ee6/go.mod h1:ZXRML051h7o4OcI0d3AaILDIad/Xw0IkXaHM17dic1Y= -github.com/tailscale/wireguard-go v0.0.0-20261125191149-d74d4ff62061 h1:wwKhjUjxTN7Xp9tEJb3I/O0CspKEPkDXy9Aje08A/gY= -github.com/tailscale/wireguard-go v0.0.0-20261125191149-d74d4ff62061/go.mod h1:Hl7pyu83xNjc1LY5e9apq2mWm8Hl76wRtJbwZ2XISqY= +github.com/tailscale/wireguard-go v0.0.0-20261204003109-5d2f71d36889 h1:+09PwX5hiw7SSqiZfQ186I4e/UGLeml0ocuyd1F84xQ= +github.com/tailscale/wireguard-go v0.0.0-20261204003109-5d2f71d36889/go.mod h1:Hl7pyu83xNjc1LY5e9apq2mWm8Hl76wRtJbwZ2XISqY= github.com/tailscale/xnet v0.0.0-20240729143630-8497ac4dab2e h1:zOGKqN5D5hHhiYUp091JqK7DPCqSARyUfduhGUY8Bek= github.com/tailscale/xnet v0.0.0-20240729143630-8497ac4dab2e/go.mod h1:orPd6JZXXRyuDusYilywte7k094d7dycXXU5YnWsrwg= github.com/tc-hib/winres v0.3.1 h1:CwRjEGrKdbi5CvZ4ID+iyVhgyfatxFoizjPhzez9Io4= diff --git a/ipn/backend.go b/ipn/backend.go index ff6bd30d7..06a891750 100644 --- a/ipn/backend.go +++ b/ipn/backend.go @@ -592,6 +592,11 @@ type PeerState struct { // so a later subscriber's initial snapshot reflects the true transition // time rather than the subscription time. PeerWireGuardStateAt time.Time + + // Protocol is the protocol of the peer's WireGuard session, + // such as [ipnstate.ProtocolWireGuardV1TSPQHybridV1]. + // It is only set in [PeerWireGuardStateEstablished]. + Protocol string `json:",omitzero"` } // IsZero reports whether no field of n is set. diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 7da78e7c1..661786fc3 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -32,6 +32,7 @@ import ( "time" "github.com/gaissmai/bart" + "github.com/tailscale/wireguard-go/device" "go4.org/mem" "go4.org/netipx" "golang.org/x/net/dns/dnsmessage" @@ -402,7 +403,7 @@ type LocalBackend struct { // peerWGState is the current non-zero WireGuard session state per peer, // keyed by stable node ID for delivery on the IPN bus. // Entries are added/updated by [LocalBackend.handlePeerWireGuardState] - // and removed when wireguard-go reports [wgengine.PeerWireGuardStateNone] + // and removed when wireguard-go reports [device.PeerSessionNone] // (including the synthetic None fired by wireguard-go's RemovePeer path // when a peer is removed from the WG config). peerWGState map[tailcfg.StableNodeID]ipn.PeerState @@ -1714,6 +1715,7 @@ func (b *LocalBackend) populatePeerStatusLocked(sb *ipnstate.StatusBuilder) { SSH_HostKeys: hostinfo.SSH_HostKeys().AsSlice(), Location: hostinfo.Location().AsStruct(), Capabilities: p.Capabilities().AsSlice(), + Protocol: b.peerWGState[p.StableID()].Protocol, } for _, f := range b.extHost.Hooks().SetPeerStatus { f(ps, p, cn) @@ -6259,16 +6261,23 @@ func (b *LocalBackend) NetMapWithPeers() *netmap.NetworkMap { // not call back into wireguard-go. Acquiring b.mu here can deadlock with // LocalBackend operations that hold b.mu while waiting for wireguard-go to make // progress. -func (b *LocalBackend) onPeerWireGuardState(peerKey key.NodePublic, state wgengine.PeerWireGuardState) { - st := peerWireGuardStateFromEngine(state) +func (b *LocalBackend) onPeerWireGuardState(peerKey key.NodePublic, si device.PeerSessionInfo) { + st := peerWireGuardStateFromDevice(si.State) + var protocol string + if si.State == device.PeerSessionEstablished { + protocol = ipnstate.ProtocolWireGuardV1 + if si.Hybrid { + protocol = ipnstate.ProtocolWireGuardV1TSPQHybridV1 + } + } // 10ms granularity is plenty for diagnostics and keeps the JSON form short. at := b.clock.Now().Round(10 * time.Millisecond) b.peerWGStateQueue.Add(func() { - b.handlePeerWireGuardState(peerKey, st, at) + b.handlePeerWireGuardState(peerKey, st, protocol, at) }) } -func (b *LocalBackend) handlePeerWireGuardState(peerKey key.NodePublic, st ipn.PeerWireGuardState, at time.Time) { +func (b *LocalBackend) handlePeerWireGuardState(peerKey key.NodePublic, st ipn.PeerWireGuardState, protocol string, at time.Time) { b.mu.Lock() defer b.mu.Unlock() @@ -6297,24 +6306,31 @@ func (b *LocalBackend) handlePeerWireGuardState(peerKey key.NodePublic, st ipn.P delete(b.peerWGStableIDByKey, peerKey) addPeerWGStateMetric(old.PeerWireGuardState, -1) } else { - old := b.peerWGState[id].PeerWireGuardState - if old == st { - return - } - if old != ipn.PeerWireGuardStateNone { - addPeerWGStateMetric(old, -1) + old := b.peerWGState[id] + if old.PeerWireGuardState == st { + if old.Protocol == protocol { + return + } + // The peer rekeyed and stays in the same state. + at = old.PeerWireGuardStateAt + } else { + if old.PeerWireGuardState != ipn.PeerWireGuardStateNone { + addPeerWGStateMetric(old.PeerWireGuardState, -1) + } + addPeerWGStateMetric(st, 1) } mak.Set(&b.peerWGState, id, ipn.PeerState{ PeerWireGuardState: st, PeerWireGuardStateAt: at, + Protocol: protocol, }) mak.Set(&b.peerWGStableIDByKey, peerKey, id) - addPeerWGStateMetric(st, 1) } b.sendToLocked(ipn.Notify{ PeerState: map[tailcfg.StableNodeID]ipn.PeerState{id: { PeerWireGuardState: st, PeerWireGuardStateAt: at, + Protocol: protocol, }}, }, allClients) } @@ -6330,18 +6346,18 @@ func addPeerWGStateMetric(state ipn.PeerWireGuardState, delta int64) { } } -func peerWireGuardStateFromEngine(state wgengine.PeerWireGuardState) ipn.PeerWireGuardState { +func peerWireGuardStateFromDevice(state device.PeerSessionState) ipn.PeerWireGuardState { switch state { - case wgengine.PeerWireGuardStateNone: + case device.PeerSessionNone: return ipn.PeerWireGuardStateNone - case wgengine.PeerWireGuardStateHandshake: + case device.PeerSessionHandshake: return ipn.PeerWireGuardStateHandshake - case wgengine.PeerWireGuardStateEstablished: + case device.PeerSessionEstablished: return ipn.PeerWireGuardStateEstablished - case wgengine.PeerWireGuardStateExpired: + case device.PeerSessionExpired: return ipn.PeerWireGuardStateExpired default: - panic(fmt.Sprintf("unexpected wgengine.PeerWireGuardState %d", state)) + panic(fmt.Sprintf("unexpected wireguard-go PeerSessionState %d", state)) } } diff --git a/ipn/ipnlocal/local_test.go b/ipn/ipnlocal/local_test.go index 3879f40fa..b4b2edefc 100644 --- a/ipn/ipnlocal/local_test.go +++ b/ipn/ipnlocal/local_test.go @@ -27,6 +27,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/tailscale/wireguard-go/device" memro "go4.org/mem" "go4.org/netipx" "golang.org/x/net/dns/dnsmessage" @@ -45,6 +46,7 @@ import ( "tailscale.com/ipn/conffile" "tailscale.com/ipn/ipnauth" "tailscale.com/ipn/ipnlocal/netmapcache" + "tailscale.com/ipn/ipnstate" "tailscale.com/ipn/store/mem" "tailscale.com/net/netcheck" "tailscale.com/net/netmon" @@ -2565,36 +2567,36 @@ func TestNotifyForSessionPeerWireGuardStateVisibility(t *testing.T) { } } -func TestPeerWireGuardStateValuesMatchWGEngine(t *testing.T) { - const unknownPeerWireGuardState wgengine.PeerWireGuardState = 255 +func TestPeerWireGuardStateValuesMatchWireguardGo(t *testing.T) { + const unknownPeerSessionState device.PeerSessionState = 255 tests := []struct { name string - in wgengine.PeerWireGuardState + in device.PeerSessionState want ipn.PeerWireGuardState }{ - {"none", wgengine.PeerWireGuardStateNone, ipn.PeerWireGuardStateNone}, - {"handshake", wgengine.PeerWireGuardStateHandshake, ipn.PeerWireGuardStateHandshake}, - {"established", wgengine.PeerWireGuardStateEstablished, ipn.PeerWireGuardStateEstablished}, - {"expired", wgengine.PeerWireGuardStateExpired, ipn.PeerWireGuardStateExpired}, + {"none", device.PeerSessionNone, ipn.PeerWireGuardStateNone}, + {"handshake", device.PeerSessionHandshake, ipn.PeerWireGuardStateHandshake}, + {"established", device.PeerSessionEstablished, ipn.PeerWireGuardStateEstablished}, + {"expired", device.PeerSessionExpired, ipn.PeerWireGuardStateExpired}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := peerWireGuardStateFromEngine(tt.in); got != tt.want { + if got := peerWireGuardStateFromDevice(tt.in); got != tt.want { t.Fatalf("converted state = %v; want %v", got, tt.want) } if got, want := uint8(tt.in), uint8(tt.want); got != want { - t.Fatalf("wgengine const = %v; want %v", got, want) + t.Fatalf("wireguard-go const = %v; want %v", got, want) } }) } defer func() { if recover() == nil { - t.Fatal("expected panic for unknown wgengine state") + t.Fatal("expected panic for unknown wireguard-go state") } }() - _ = peerWireGuardStateFromEngine(unknownPeerWireGuardState) + _ = peerWireGuardStateFromDevice(unknownPeerSessionState) } func TestPeerWireGuardStateWatchInitialThenDeltas(t *testing.T) { @@ -2615,10 +2617,10 @@ func TestPeerWireGuardStateWatchInitialThenDeltas(t *testing.T) { }) t1 := time.Unix(1700000000, 0) - b.handlePeerWireGuardState(peer1.Key, ipn.PeerWireGuardStateEstablished, t1) - b.handlePeerWireGuardState(peer1.Key, ipn.PeerWireGuardStateEstablished, t1.Add(time.Second)) - defer b.handlePeerWireGuardState(peer1.Key, ipn.PeerWireGuardStateNone, time.Now()) - defer b.handlePeerWireGuardState(peer2.Key, ipn.PeerWireGuardStateNone, time.Now()) + b.handlePeerWireGuardState(peer1.Key, ipn.PeerWireGuardStateEstablished, "", t1) + b.handlePeerWireGuardState(peer1.Key, ipn.PeerWireGuardStateEstablished, "", t1.Add(time.Second)) + defer b.handlePeerWireGuardState(peer1.Key, ipn.PeerWireGuardStateNone, "", time.Now()) + defer b.handlePeerWireGuardState(peer2.Key, ipn.PeerWireGuardStateNone, "", time.Now()) ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -2629,7 +2631,7 @@ func TestPeerWireGuardStateWatchInitialThenDeltas(t *testing.T) { defer close(doneCh) var got int b.WatchNotificationsAs(ctx, nil, ipn.NotifyPeerWireGuardState, func() { - b.onPeerWireGuardState(peer2.Key, wgengine.PeerWireGuardStateHandshake) + b.onPeerWireGuardState(peer2.Key, device.PeerSessionInfo{State: device.PeerSessionHandshake}) }, func(n *ipn.Notify) bool { gotCh <- n got++ @@ -2677,25 +2679,49 @@ func TestPeerWireGuardStateMetrics(t *testing.T) { Key: makeNodeKeyFromID(1), } b.currentNode().SetNetMap(&netmap.NetworkMap{ - Peers: []tailcfg.NodeView{peer.View()}, + SelfNode: (&tailcfg.Node{ID: 100}).View(), + Peers: []tailcfg.NodeView{peer.View()}, }) now := time.Now() - defer b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateNone, now) + defer b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateNone, "", now) baseHandshake := metricPeerWGStateHandshake.Value() baseEstablished := metricPeerWGStateEstablished.Value() baseExpired := metricPeerWGStateExpired.Value() - b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateEstablished, now) + b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateEstablished, "", now) if got, want := metricPeerWGStateEstablished.Value(), baseEstablished+1; got != want { t.Fatalf("established gauge = %v; want %v", got, want) } - b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateEstablished, now) + b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateEstablished, "", now) if got, want := metricPeerWGStateEstablished.Value(), baseEstablished+1; got != want { t.Fatalf("established gauge after no-op = %v; want %v", got, want) } - b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateHandshake, now) + // A rekey with a different handshake type keeps the state and its time. + b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateEstablished, ipnstate.ProtocolWireGuardV1TSPQHybridV1, now.Add(time.Second)) + if got, want := metricPeerWGStateEstablished.Value(), baseEstablished+1; got != want { + t.Fatalf("established gauge after rekey = %v; want %v", got, want) + } + b.mu.Lock() + gotState := b.peerWGState[peer.StableID] + b.mu.Unlock() + wantState := ipn.PeerState{ + PeerWireGuardState: ipn.PeerWireGuardStateEstablished, + PeerWireGuardStateAt: now, + Protocol: ipnstate.ProtocolWireGuardV1TSPQHybridV1, + } + if gotState != wantState { + t.Fatalf("peer state after rekey = %+v; want %+v", gotState, wantState) + } + sb := &ipnstate.StatusBuilder{WantPeers: true} + b.UpdateStatus(sb) + ps := sb.Status().Peer[peer.Key] + if got, want := ps.Protocol, ipnstate.ProtocolWireGuardV1TSPQHybridV1; got != want { + t.Fatalf("PeerStatus.Protocol = %q; want %q", got, want) + } + + b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateHandshake, "", now) if got, want := metricPeerWGStateEstablished.Value(), baseEstablished; got != want { t.Fatalf("established gauge after transition = %v; want %v", got, want) } @@ -2703,7 +2729,7 @@ func TestPeerWireGuardStateMetrics(t *testing.T) { t.Fatalf("handshake gauge = %v; want %v", got, want) } - b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateExpired, now) + b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateExpired, "", now) if got, want := metricPeerWGStateHandshake.Value(), baseHandshake; got != want { t.Fatalf("handshake gauge after transition = %v; want %v", got, want) } @@ -2711,7 +2737,7 @@ func TestPeerWireGuardStateMetrics(t *testing.T) { t.Fatalf("expired gauge = %v; want %v", got, want) } - b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateNone, now) + b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateNone, "", now) if got, want := metricPeerWGStateExpired.Value(), baseExpired; got != want { t.Fatalf("expired gauge after none = %v; want %v", got, want) } @@ -2731,7 +2757,7 @@ func TestPeerWireGuardStateCallbackDoesNotBlockOnLocalBackendMu(t *testing.T) { b.mu.Lock() done := make(chan struct{}) go func() { - b.onPeerWireGuardState(peer.Key, wgengine.PeerWireGuardStateEstablished) + b.onPeerWireGuardState(peer.Key, device.PeerSessionInfo{State: device.PeerSessionEstablished}) close(done) }() select { @@ -2743,7 +2769,7 @@ func TestPeerWireGuardStateCallbackDoesNotBlockOnLocalBackendMu(t *testing.T) { b.mu.Unlock() _ = b.peerWGStateQueue.Wait(context.Background()) - b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateNone, time.Now()) + b.handlePeerWireGuardState(peer.Key, ipn.PeerWireGuardStateNone, "", time.Now()) } func TestSetControlClientStatusSendsFullNetmapAsPeerChanges(t *testing.T) { diff --git a/ipn/ipnlocal/state_test.go b/ipn/ipnlocal/state_test.go index e04ce0879..56025ba2d 100644 --- a/ipn/ipnlocal/state_test.go +++ b/ipn/ipnlocal/state_test.go @@ -21,6 +21,7 @@ import ( "github.com/gaissmai/bart" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/tailscale/wireguard-go/device" "go4.org/netipx" "tailscale.com/control/controlclient" @@ -2353,7 +2354,7 @@ func (e *mockEngine) syncedPeersSince(n int) []key.NodePublic { } func (e *mockEngine) MarkDevicePeerForHandshake(key.NodePublic) {} -func (e *mockEngine) SetPeerSessionStateFunc(func(key.NodePublic, wgengine.PeerWireGuardState)) { +func (e *mockEngine) SetPeerSessionStateFunc(func(key.NodePublic, device.PeerSessionInfo)) { } func (e *mockEngine) SetNetLogSource(wgengine.NetLogSource) {} func (e *mockEngine) SetPeerPriorityMessageOnEstablishmentFunc(fn func(key.NodePublic) (msg []byte)) { diff --git a/ipn/ipnstate/ipnstate.go b/ipn/ipnstate/ipnstate.go index ab007bd5a..62f0b65d5 100644 --- a/ipn/ipnstate/ipnstate.go +++ b/ipn/ipnstate/ipnstate.go @@ -229,6 +229,15 @@ type PeerStatusLite struct { LastHandshake time.Time } +// The WireGuard session protocols reported in [PeerStatus.Protocol]. +const ( + // ProtocolWireGuardV1 is WireGuard with the Noise IKpsk2 handshake. + ProtocolWireGuardV1 = "wg-v1" + // ProtocolWireGuardV1TSPQHybridV1 is WireGuard with the hybrid + // post-quantum Noise IKhfs+psk2 handshake using ML-KEM-768. + ProtocolWireGuardV1TSPQHybridV1 = "wg-v1-ts-pqh-v1" +) + // PeerStatus describes a peer node and its current state. // WARNING: The fields in PeerStatus are merged by the AddPeer method in the StatusBuilder. // When adding a new field to PeerStatus, you must update AddPeer to handle merging @@ -281,6 +290,11 @@ type PeerStatus struct { ExitNode bool // true if this is the currently selected exit node. ExitNodeOption bool // true if this node can be an exit node (offered && approved) + // Protocol is the protocol of the current WireGuard session with this peer, + // such as [ProtocolWireGuardV1TSPQHybridV1]. + // It is empty if there is no session. + Protocol string `json:",omitzero"` + // Active is whether the node was recently active. The // definition is somewhat undefined but has historically and // currently means that there was some packet sent to this @@ -535,6 +549,9 @@ func (sb *StatusBuilder) AddPeer(peer key.NodePublic, st *PeerStatus) { if v := st.LastHandshake; !v.IsZero() { e.LastHandshake = v } + if v := st.Protocol; v != "" { + e.Protocol = v + } if v := st.Created; !v.IsZero() { e.Created = v } @@ -688,6 +705,9 @@ table tbody tr:nth-child(even) td { background-color: #f5f5f5; } ) f("