mirror of
https://github.com/tailscale/tailscale.git
synced 2026-12-03 23:22:23 -08:00
Add Network.ListenPacket, making Network a nettype.PacketListener with in-memory UDP sockets. Packets go by exact destination address and port. Sending never blocks; packets to an address without a socket, or to a full receive queue, are dropped. An unspecified or empty listen IP binds the family's loopback address, and port zero picks the next ephemeral port in rotation, so a just-closed socket's port isn't handed right back out, as with an OS. Reads block only on channels and timers, including for read deadlines, so the sockets work in testing/synctest bubbles. That's for running magicsock (via its TestOnlyPacketListener) and STUN (via stuntest.ServeWithPacketListener) on an in-memory network with fake time. Updates #22831 Change-Id: Id7043412ca036b075927c6352c663d73f2b8657f Signed-off-by: Brad Fitzpatrick <[email protected]>