Skip to main content

PeerTracker

Struct PeerTracker 

Source
pub struct PeerTracker { /* private fields */ }
Expand description

Actor that tracks peer delta updates and emits new states.

Implementations§

Source§

impl PeerTracker

Source

pub async fn peer_by_name( &mut self, ctx: &mut Context<Self, DelegatedReply<Option<Node>>>, name: String, ) -> DelegatedReply<Option<Node>>

Lookup a peer by name.

Waits until we’ve received at least one peer update from control.

Source

pub fn peer_by_accepted_route( &mut self, ctx: &mut Context<Self, DelegatedReply<Vec<Node>>>, ip: IpAddr, ) -> DelegatedReply<Vec<Node>>

Lookup all peers that accept packets addressed to the given IP.

This includes the peer’s tailnet address and any subnet routes it provides. Only the peers with the most specific subnet route match that covers ip will be returned.

E.g., suppose:

  • We’re querying for 10.1.2.3
  • PeerA and PeerB have accepted routes for 10.1.2.0/24
  • PeerC has an accepted route for 10.1.0.0/16

Only PeerA and PeerB will be returned, since they have the most specific prefix match.

Source

pub fn peer_by_tailnet_ip( &mut self, ctx: &mut Context<Self, DelegatedReply<Option<Node>>>, ip: IpAddr, ) -> DelegatedReply<Option<Node>>

Lookup the peer that has the given tailnet IP address.

Source

pub fn get_status( &mut self, ctx: &mut Context<Self, DelegatedReply<Vec<StatusNode>>>, ) -> DelegatedReply<Vec<StatusNode>>

Build the peer entries of a Status snapshot.

Returns one StatusNode per known peer. The self node is not included here (it lives in the control runner); Runtime::status combines both.

Waits until we’ve received at least one peer update from control.

Source

pub fn whois( &mut self, ctx: &mut Context<Self, DelegatedReply<Option<WhoIs>>>, addr: SocketAddr, ) -> DelegatedReply<Option<WhoIs>>

Resolve which node owns a tailnet source address.

Maps the source IP of addr to the owning node via the tailnet-IP index, returning a WhoIs. The port is ignored (a tailnet IP uniquely identifies a node).

The resulting WhoIs carries no user/login or capability data: this fork’s domain Node does not retain those wire fields. See the status module docs for the gap.

Waits until we’ve received at least one peer update from control.

Source

pub fn watch_netmap(&self) -> Receiver<Vec<StatusNode>>

Subscribe to netmap peer-change events.

Returns a watch::Receiver whose value is the current set of peer StatusNodes, updated on every netmap state update from control. Embedders can await changes via watch::Receiver::changed to react to peers joining, leaving, or changing.

The receiver’s initial value is the peer set at subscription time (empty before the first netmap update). This is a peer-only view; combine with the self node from Runtime::status when a full snapshot is needed.

Trait Implementations§

Source§

impl Actor for PeerTracker

Source§

type Args = Env

Arguments to initialize the actor. Read more
Source§

type Error = Error

Actor error type. Read more
Source§

async fn on_start( env: Self::Args, slf: ActorRef<Self>, ) -> Result<Self, Self::Error>

Called when the actor starts, before it processes any messages. Read more
Source§

fn name() -> &'static str

The name of the actor, which can be useful for logging or debugging. Read more
Source§

fn on_message( &mut self, msg: Box<dyn DynMessage<Self>>, actor_ref: ActorRef<Self>, tx: Option<Sender<Result<Box<dyn Any + Send>, SendError<Box<dyn Any + Send>, Box<dyn Any + Send>>>>>, stop: &mut bool, ) -> impl Future<Output = Result<(), Box<dyn ReplyError>>> + Send

Called when the actor receives a message to be processed. Read more
Source§

fn on_panic( &mut self, actor_ref: WeakActorRef<Self>, err: PanicError, ) -> impl Future<Output = Result<ControlFlow<ActorStopReason>, Self::Error>> + Send

Called when the actor encounters a panic or an error during “tell” message handling. Read more
Called when a linked actor dies. Read more
Source§

fn on_stop( &mut self, actor_ref: WeakActorRef<Self>, reason: ActorStopReason, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Called before the actor stops. Read more
Source§

fn next( &mut self, actor_ref: WeakActorRef<Self>, mailbox_rx: &mut MailboxReceiver<Self>, ) -> impl Future<Output = Option<Signal<Self>>> + Send

Awaits the next signal typically from the mailbox. Read more
Source§

impl Message<Arc<StateUpdate>> for PeerTracker

Source§

type Reply = ()

The reply sent back to the message caller.
Source§

async fn handle( &mut self, msg: Arc<StateUpdate>, _ctx: &mut Context<Self, Self::Reply>, )

Handler for this message.
Source§

impl Message<GetStatus> for PeerTracker

Source§

type Reply = DelegatedReply<Vec<StatusNode>>

The reply sent back to the message caller.
Source§

async fn handle( &mut self, msg: GetStatus, ctx: &mut Context<Self, Self::Reply>, ) -> Self::Reply

Handler for this message.
Source§

impl Message<PeerByAcceptedRoute> for PeerTracker

Source§

type Reply = DelegatedReply<Vec<Node>>

The reply sent back to the message caller.
Source§

async fn handle( &mut self, msg: PeerByAcceptedRoute, ctx: &mut Context<Self, Self::Reply>, ) -> Self::Reply

Handler for this message.
Source§

impl Message<PeerByName> for PeerTracker

Source§

type Reply = DelegatedReply<Option<Node>>

The reply sent back to the message caller.
Source§

async fn handle( &mut self, msg: PeerByName, ctx: &mut Context<Self, Self::Reply>, ) -> Self::Reply

Handler for this message.
Source§

impl Message<PeerByTailnetIp> for PeerTracker

Source§

type Reply = DelegatedReply<Option<Node>>

The reply sent back to the message caller.
Source§

async fn handle( &mut self, msg: PeerByTailnetIp, ctx: &mut Context<Self, Self::Reply>, ) -> Self::Reply

Handler for this message.
Source§

impl Message<RepublishState> for PeerTracker

Source§

type Reply = ()

The reply sent back to the message caller.
Source§

async fn handle( &mut self, _msg: RepublishState, _ctx: &mut Context<Self, Self::Reply>, )

Handler for this message.
Source§

impl Message<WatchNetmap> for PeerTracker

Source§

type Reply = Receiver<Vec<StatusNode>>

The reply sent back to the message caller.
Source§

async fn handle( &mut self, msg: WatchNetmap, _ctx: &mut Context<Self, Self::Reply>, ) -> Self::Reply

Handler for this message.
Source§

impl Message<Whois> for PeerTracker

Source§

type Reply = DelegatedReply<Option<WhoIs>>

The reply sent back to the message caller.
Source§

async fn handle( &mut self, msg: Whois, ctx: &mut Context<Self, Self::Reply>, ) -> Self::Reply

Handler for this message.

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<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<A, T> DynMessage<A> for T
where A: Actor + Message<T>, T: Send + 'static,

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>>

Handles the dyn message with the provided actor state, ref, and reply sender.
Source§

fn as_any(self: Box<T>) -> Box<dyn Any>

Casts the type to a Box<dyn Any>.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<A> Spawn for A
where A: Actor,

Source§

fn spawn(args: Self::Args) -> ActorRef<Self>

Spawns the actor in a Tokio task, running asynchronously with a default bounded mailbox. Read more
Source§

fn spawn_default() -> ActorRef<Self>
where Self::Args: Default,

Spawns the actor with default initialization in a Tokio task. Read more
Source§

fn spawn_with_mailbox( args: Self::Args, _: (MailboxSender<Self>, MailboxReceiver<Self>), ) -> ActorRef<Self>

Spawns the actor in a Tokio task with a specific mailbox configuration. Read more
Spawns and links the actor in a Tokio task with a default bounded mailbox. Read more
Spawns and links the actor in a Tokio task with a specific mailbox configuration. Read more
Source§

fn spawn_in_thread(args: Self::Args) -> ActorRef<Self>

Spawns the actor in its own dedicated thread with a default bounded mailbox. Read more
Source§

fn spawn_in_thread_with_mailbox( args: Self::Args, _: (MailboxSender<Self>, MailboxReceiver<Self>), ) -> ActorRef<Self>

Spawns the actor in its own dedicated thread with a specific mailbox configuration. Read more
Source§

fn prepare() -> PreparedActor<Self>

Creates a new prepared actor, allowing access to its ActorRef before spawning. Read more
Source§

fn prepare_with_mailbox( _: (MailboxSender<Self>, MailboxReceiver<Self>), ) -> PreparedActor<Self>

Creates a new prepared actor with a specific mailbox configuration, allowing access to its ActorRef before spawning. Read more
Source§

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

Source§

type Error = Infallible

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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