pub struct DiscoAdvertisementState {
pub disco_key: [u8; 32],
pub self_addrs: Vec<IpAddr>,
pub peers: HashMap<PeerId, AdvertisementTarget>,
}Expand description
Where this node sends a TSMP disco-key advertisement, and what it puts in one.
The send half of Go’s capability version 144 (packet.TSMPDiscoKeyAdvertisement): when a
WireGuard session with a peer is established, this node announces its own disco public key to
that peer over TSMP, so the peer can learn (or re-learn) the key without waiting for a netmap
update from control. It is the mirror image of the receive half in
[filter_inbound_from_peer], and both are unconditional — a real Go peer sends us one whether
or not we send one back.
This is the netmap state Go’s magicsock.Conn.PriorityMessageForPeer reads, snapshotted into
the dataplane so building the message stays a cheap, synchronous, allocation-only step on the
datapath. wireguard-go requires the same of its callback: “must be cheap and must not call back
into the Device”. The runtime refreshes the snapshot whenever the netmap changes.
Fields§
§disco_key: [u8; 32]This node’s own disco public key, raw (Go Conn.DiscoPublicKey()). The all-zero key means
“no disco key”, and nothing is ever advertised — Go’s first refusal.
self_addrs: Vec<IpAddr>This node’s own tailnet addresses, in the order control sent them (Go self.Addresses(),
already narrowed to the single-IP prefixes selfIPMatchingFamily accepts). The
advertisement’s source is the first entry matching the destination’s family.
peers: HashMap<PeerId, AdvertisementTarget>Where to send an advertisement, per peer. A peer absent from this map is never advertised
to — Go’s endpointForNodeKey miss.
Implementations§
Source§impl DiscoAdvertisementState
impl DiscoAdvertisementState
Sourcepub fn advertisement_for(&self, peer: PeerId) -> Option<Vec<u8>>
pub fn advertisement_for(&self, peer: PeerId) -> Option<Vec<u8>>
The marshalled TSMP disco-key advertisement to send peer on session establishment, or
None if this node must not advertise to it.
Go magicsock.Conn.PriorityMessageForPeer, refusal for refusal — every one of these is a
silent “send nothing”, never a fallback to some other message:
- No disco key of our own (
disco.IsZero()): there is nothing to advertise. - Unknown peer (
endpointForNodeKeymiss, or!self.Valid()): the netmap snapshot has no destination address for this WireGuard peer, so any address we invented would be a guess. - A WireGuard-only peer (
ep.isWireguardOnly): “Do not send TSMP messages to peers that only speaks wireguard.” - No source address in the destination’s family (
selfIPMatchingFamilyreturning the zeroAddr): an IPv4-only node has nothing to put in the source field of a packet to a peer’s IPv6 address. - A marshal refusal, which by construction of (4) cannot happen — see
ts_packet::tsmp::DiscoKeyAdvertisement::marshal.
Trait Implementations§
Source§impl Clone for DiscoAdvertisementState
impl Clone for DiscoAdvertisementState
Source§fn clone(&self) -> DiscoAdvertisementState
fn clone(&self) -> DiscoAdvertisementState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DiscoAdvertisementState
impl Debug for DiscoAdvertisementState
Source§impl Default for DiscoAdvertisementState
impl Default for DiscoAdvertisementState
Source§fn default() -> DiscoAdvertisementState
fn default() -> DiscoAdvertisementState
Auto Trait Implementations§
impl Freeze for DiscoAdvertisementState
impl RefUnwindSafe for DiscoAdvertisementState
impl Send for DiscoAdvertisementState
impl Sync for DiscoAdvertisementState
impl Unpin for DiscoAdvertisementState
impl UnsafeUnpin for DiscoAdvertisementState
impl UnwindSafe for DiscoAdvertisementState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more