Skip to main content

DiscoAdvertisementState

Struct DiscoAdvertisementState 

Source
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

Source

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:

  1. No disco key of our own (disco.IsZero()): there is nothing to advertise.
  2. Unknown peer (endpointForNodeKey miss, or !self.Valid()): the netmap snapshot has no destination address for this WireGuard peer, so any address we invented would be a guess.
  3. A WireGuard-only peer (ep.isWireguardOnly): “Do not send TSMP messages to peers that only speaks wireguard.”
  4. No source address in the destination’s family (selfIPMatchingFamily returning the zero Addr): an IPv4-only node has nothing to put in the source field of a packet to a peer’s IPv6 address.
  5. A marshal refusal, which by construction of (4) cannot happen — see ts_packet::tsmp::DiscoKeyAdvertisement::marshal.

Trait Implementations§

Source§

impl Clone for DiscoAdvertisementState

Source§

fn clone(&self) -> DiscoAdvertisementState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DiscoAdvertisementState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DiscoAdvertisementState

Source§

fn default() -> DiscoAdvertisementState

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more