2025-05-09 14:50:01 -07:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
|
|
|
package magicsock
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"tailscale.com/disco"
|
2025-05-16 13:51:40 -07:00
|
|
|
"tailscale.com/types/key"
|
2025-05-09 14:50:01 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestRelayManagerInitAndIdle(t *testing.T) {
|
|
|
|
rm := relayManager{}
|
|
|
|
rm.allocateAndHandshakeAllServers(&endpoint{})
|
|
|
|
<-rm.runLoopStoppedCh
|
|
|
|
|
|
|
|
rm = relayManager{}
|
2025-05-16 13:51:40 -07:00
|
|
|
rm.stopWork(&endpoint{})
|
2025-05-09 14:50:01 -07:00
|
|
|
<-rm.runLoopStoppedCh
|
|
|
|
|
|
|
|
rm = relayManager{}
|
2025-05-16 13:51:40 -07:00
|
|
|
rm.handleCallMeMaybeVia(&endpoint{c: &Conn{discoPrivate: key.NewDisco()}}, &disco.CallMeMaybeVia{ServerDisco: key.NewDisco().Public()})
|
2025-05-09 14:50:01 -07:00
|
|
|
<-rm.runLoopStoppedCh
|
|
|
|
|
|
|
|
rm = relayManager{}
|
wgengine/magicsock: make endpoint.bestAddr Geneve-aware (#16195)
This commit adds a new type to magicsock, epAddr, which largely ends up
replacing netip.AddrPort in packet I/O paths throughout, enabling
Geneve encapsulation over UDP awareness.
The conn.ReceiveFunc for UDP has been revamped to fix and more clearly
distinguish the different classes of packets we expect to receive: naked
STUN binding messages, naked disco, naked WireGuard, Geneve-encapsulated
disco, and Geneve-encapsulated WireGuard.
Prior to this commit, STUN matching logic in the RX path could swallow
a naked WireGuard packet if the keypair index, which is randomly
generated, happened to overlap with a subset of the STUN magic cookie.
Updates tailscale/corp#27502
Updates tailscale/corp#29326
Signed-off-by: Jordan Whited <jordan@tailscale.com>
2025-06-06 09:46:29 -07:00
|
|
|
rm.handleGeneveEncapDiscoMsgNotBestAddr(&disco.BindUDPRelayEndpointChallenge{}, &discoInfo{}, epAddr{})
|
2025-05-09 14:50:01 -07:00
|
|
|
<-rm.runLoopStoppedCh
|
|
|
|
}
|