pub enum ExitNodeSelector {
StableId(StableId),
Ip(IpAddr),
Name(String),
}Expand description
How this node selects which peer to use as its exit node (--exit-node in the Go client).
Mirrors the Go client’s --exit-node, which accepts a tailnet IP, a MagicDNS name, or a stable
node ID, and resolves it to a StableNodeID (resolveExitNodeIPLocked). We keep the selector
unresolved and re-run ExitNodeSelector::resolve against the live peer set on every route
rebuild, so an IP- or name-based selection follows the peer as the netmap changes (e.g. the
exit node re-registers under a new stable id).
A selector can be parsed from a string with str::parse/FromStr,
auto-detecting the variant the way the Go CLI’s --exit-node does: a value that parses as an IP
address becomes ExitNodeSelector::Ip, anything else becomes ExitNodeSelector::Name.
Stable-id selection is available only by constructing ExitNodeSelector::StableId directly
(it is not auto-detected, since a stable id is otherwise indistinguishable from a hostname).
Variants§
StableId(StableId)
Select the peer with this exact stable node id.
Ip(IpAddr)
Select the peer whose tailnet address is this IP.
Name(String)
Select the peer matching this bare hostname or MagicDNS name (case-insensitive, optional
trailing dot), as per Node::matches_name.
Implementations§
Source§impl ExitNodeSelector
impl ExitNodeSelector
Sourcepub fn resolve<'a>(
&self,
peers: impl Iterator<Item = &'a Node>,
) -> Option<StableId>
pub fn resolve<'a>( &self, peers: impl Iterator<Item = &'a Node>, ) -> Option<StableId>
Resolve this selector to the stable id of the matching peer, if any, given the current set of peers.
Resolution is deterministic: if a selector somehow matches more than one peer (e.g. two
peers sharing a MagicDNS name during a transient netmap state), the peer with the smallest
StableId is chosen. This matters because both the outbound route table and the inbound
source filter resolve independently; a deterministic tiebreak guarantees they pick the
same peer, preserving the cryptokey-routing coupling that prevents source-spoofing.
Returns None when no peer matches (a stale/typo’d selector). Callers treat None as
fail-closed: no peer is granted a default route, so internet-bound traffic is dropped.
Trait Implementations§
Source§impl Clone for ExitNodeSelector
impl Clone for ExitNodeSelector
Source§fn clone(&self) -> ExitNodeSelector
fn clone(&self) -> ExitNodeSelector
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 ExitNodeSelector
impl Debug for ExitNodeSelector
Source§impl<'de> Deserialize<'de> for ExitNodeSelector
impl<'de> Deserialize<'de> for ExitNodeSelector
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ExitNodeSelector
Source§impl FromStr for ExitNodeSelector
impl FromStr for ExitNodeSelector
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parse a selector from a string, auto-detecting IP vs. name (matching the Go CLI’s
--exit-node). Parsing never fails: a non-IP string is taken as a MagicDNS name.
Source§type Err = Infallible
type Err = Infallible
Source§impl PartialEq for ExitNodeSelector
impl PartialEq for ExitNodeSelector
Source§fn eq(&self, other: &ExitNodeSelector) -> bool
fn eq(&self, other: &ExitNodeSelector) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ExitNodeSelector
impl Serialize for ExitNodeSelector
impl StructuralPartialEq for ExitNodeSelector
Auto Trait Implementations§
impl Freeze for ExitNodeSelector
impl RefUnwindSafe for ExitNodeSelector
impl Send for ExitNodeSelector
impl Sync for ExitNodeSelector
impl Unpin for ExitNodeSelector
impl UnsafeUnpin for ExitNodeSelector
impl UnwindSafe for ExitNodeSelector
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.