pub struct PeerDb { /* private fields */ }Expand description
A database that stores a map of peers by PeerId and multiple indices.
Assumes that all indexed fields are unique per-node, with a few notable exceptions:
- Hostname may be duplicated, though the fqdn (including the tailnet component) may not be.
- Accepted routes may overlap.
Implementations§
Source§impl PeerDb
impl PeerDb
Sourcepub fn upsert(&mut self, new: &Node) -> PeerId
pub fn upsert(&mut self, new: &Node) -> PeerId
Upsert a node into the peer db.
The StableNodeId is used as the primary key to identify the node.
Sourcepub fn remove(&mut self, field: &dyn IndexedField) -> Option<(PeerId, Node)>
pub fn remove(&mut self, field: &dyn IndexedField) -> Option<(PeerId, Node)>
Remove a peer by a given indexed field.
Sourcepub fn get(&self, field: &dyn IndexedField) -> Option<(PeerId, &Node)>
pub fn get(&self, field: &dyn IndexedField) -> Option<(PeerId, &Node)>
Get the node with the given field.
Sourcepub fn get_route(&self, route: IpNet) -> impl Iterator<Item = (PeerId, &Node)>
pub fn get_route(&self, route: IpNet) -> impl Iterator<Item = (PeerId, &Node)>
Get the nodes with the closest matching route.
Sourcepub fn has(&self, field: &dyn IndexedField) -> Option<PeerId>
pub fn has(&self, field: &dyn IndexedField) -> Option<PeerId>
Check whether there is a peer with the given field in the db.
Sourcepub fn peer_by_known_disco_key(
&self,
key: &DiscoPublicKey,
) -> Option<(PeerId, &Node, DiscoKeyMatch)>
pub fn peer_by_known_disco_key( &self, key: &DiscoPublicKey, ) -> Option<(PeerId, &Node, DiscoKeyMatch)>
Resolve an inbound disco frame’s sender key to the peer that owns it, accepting either
of that peer’s two known disco keys — Go endpoint.checkAndUpdateDiscoKey.
The active key is tried first, so a key that is one peer’s active key and another peer’s
stale inactive one resolves to the peer that is actually using it. A key belonging to
neither slot of any peer returns None and must be refused by the caller: that refusal is
what stops an unknown disco key from opening a path or being attributed to a peer.
Two peers can transiently claim the same key under netmap churn (see
disco_key_reassigned_across_peers_no_panic); like every other index here the answer is the
last writer’s, never a panic.
Sourcepub fn set_inactive_disco_key(
&mut self,
id: PeerId,
key: Option<DiscoPublicKey>,
)
pub fn set_inactive_disco_key( &mut self, id: PeerId, key: Option<DiscoPublicKey>, )
Register (or clear) the peer’s known-but-inactive disco key, so ingress under it still resolves to the peer.
A control Node carries a single disco key, so the second slot of Go’s endpointDisco
cannot come in through upsert; the peer tracker — which owns that state —
writes it here immediately after each upsert. Passing None retracts the entry, which is
what a peer that has only ever had one key needs.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PeerDb
impl RefUnwindSafe for PeerDb
impl Send for PeerDb
impl Sync for PeerDb
impl Unpin for PeerDb
impl UnsafeUnpin for PeerDb
impl UnwindSafe for PeerDb
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<A, T> DynMessage<A> for T
impl<A, T> DynMessage<A> for T
Source§fn handle_dyn<'a>(
self: Box<T>,
state: &'a mut A,
actor_ref: ActorRef<A>,
tx: Option<Sender<Result<Box<dyn Any + Send>, SendError<Box<dyn Any + Send>, Box<dyn Any + Send>>>>>,
stop: &'a mut bool,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn ReplyError>>> + Send + 'a>>
fn handle_dyn<'a>( self: Box<T>, state: &'a mut A, actor_ref: ActorRef<A>, tx: Option<Sender<Result<Box<dyn Any + Send>, SendError<Box<dyn Any + Send>, Box<dyn Any + Send>>>>>, stop: &'a mut bool, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn ReplyError>>> + Send + 'a>>
impl<T> ErasedDestructor for Twhere
T: 'static,
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