Skip to main content

LinkManager

Struct LinkManager 

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

Manages multiple links, link destinations, and request/response.

Implementations§

Source§

impl LinkManager

Source

pub fn flush_channel_tx(&mut self, link_id: &LinkId)

Flush the channel TX ring for a link, clearing outstanding messages. Called after holepunch completion where signaling messages are fire-and-forget.

Source

pub fn send_channel_message( &mut self, link_id: &LinkId, msgtype: u16, payload: &[u8], rng: &mut dyn Rng, ) -> Result<Vec<LinkManagerAction>, String>

Send a channel message on a link.

Source§

impl LinkManager

Source

pub fn send_deferred_response( &mut self, link_id: &LinkId, request_id: &[u8; 16], response_data: &[u8], rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>

Send the value for a previously accepted deferred request.

Source

pub fn send_management_response( &mut self, link_id: &LinkId, request_id: &[u8; 16], response_data: &[u8], rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>

Send a management response on a link. Called by the driver after building the response for a ManagementRequest.

Source

pub fn send_request( &mut self, link_id: &LinkId, path: &str, data: &[u8], rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>

Send a request on a link.

data is the msgpack-encoded request data value (e.g. msgpack([True]) for /status).

Uses Python-compatible format: plaintext = msgpack([timestamp, path_hash_bytes, data_value]). Returns actions (the encrypted request packet). The response will arrive later via handle_local_delivery with CONTEXT_RESPONSE.

Source

pub fn send_request_with_max_response_size( &mut self, link_id: &LinkId, path: &str, data: &[u8], max_response_size: Option<usize>, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>

Send a request with an optional maximum accepted response size.

Source§

impl LinkManager

Source

pub fn accept_resource( &mut self, link_id: &LinkId, resource_hash: &[u8], accept: bool, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>

Accept or reject a pending resource (for AcceptApp strategy).

Source

pub fn send_resource( &mut self, link_id: &LinkId, data: &[u8], metadata: Option<&[u8]>, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>

Start sending a resource on a link.

Source

pub fn send_resource_with_auto_compress( &mut self, link_id: &LinkId, data: &[u8], metadata: Option<&[u8]>, auto_compress: bool, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>

Start sending a resource on a link, controlling automatic compression.

Source

pub fn send_resource_stream( &mut self, link_id: &LinkId, transfer_id: ResourceTransferId, reader: Box<dyn Read + Send>, declared_length: u64, metadata: Option<Vec<u8>>, auto_compress: bool, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>

Start a bounded-memory Resource transfer from a sequential reader.

The declared-length reader is consumed directly. Unlike the upstream zero-stat compatibility path, no temporary buffered proxy must be flushed and rewound before its size or first segment can be observed.

Source

pub fn set_resource_strategy( &mut self, link_id: &LinkId, strategy: ResourceStrategy, )

Set the resource acceptance strategy for a link.

Source

pub fn set_resource_receive_mode( &mut self, link_id: &LinkId, mode: ResourceReceiveMode, )

Source§

impl LinkManager

Source

pub fn new() -> Self

Create a new empty link manager.

Source

pub fn register_management_path(&mut self, path_hash: [u8; 16])

Register a path hash as a management path. Management requests are returned as ManagementRequest actions for the driver to handle (since they need access to engine state).

Source

pub fn get_derived_key(&self, link_id: &LinkId) -> Option<Vec<u8>>

Get the derived session key for a link (needed for hole-punch token derivation).

Source

pub fn remote_identity_hash(&self, link_id: &LinkId) -> Option<[u8; 16]>

Return the identity hash learned from a successful LINKIDENTIFY exchange.

Return best-known routing hint for link packets.

Set the best-known outbound route for a link.

Register a destination that can accept incoming links.

Configure the maximum request size for this destination.

The new limit also applies to responder links that are already active. Returns false when the destination is not registered.

Deregister a link destination.

Source

pub fn register_request_handler<F>( &mut self, path: &str, allowed_list: Option<Vec<[u8; 16]>>, handler: F, )
where F: Fn(LinkId, &str, &[u8], Option<&([u8; 16], [u8; 64])>) -> Option<Vec<u8>> + Send + 'static,

Register a request handler for a given path.

path: the request path string (e.g. “/status”) allowed_list: None = allow all, Some(list) = restrict to these identity hashes handler: called with (link_id, path, request_data, remote_identity) -> Option

Source

pub fn register_request_handler_response<F>( &mut self, path: &str, allowed_list: Option<Vec<[u8; 16]>>, handler: F, )
where F: Fn(LinkId, &str, &[u8], Option<&([u8; 16], [u8; 64])>) -> Option<RequestResponse> + Send + 'static,

Register a request handler that can return resource responses with metadata.

Source

pub fn register_deferred_request_handler<F>( &mut self, path: &str, allowed_list: Option<Vec<[u8; 16]>>, handler: F, )
where F: Fn(LinkId, &str, [u8; 16], &[u8], Option<&([u8; 16], [u8; 64])>) + Send + 'static,

Register a request handler that produces its response asynchronously.

Create an outbound link to a destination.

dest_sig_pub_bytes is the destination’s Ed25519 signing public key (needed to verify LRPROOF). In Python this comes from the Destination’s Identity.

Returns (link_id, actions). The first action will be a SendPacket with the LINKREQUEST.

Source

pub fn handle_local_delivery( &mut self, dest_hash: [u8; 16], raw: &[u8], packet_hash: [u8; 32], receiving_interface: InterfaceId, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>

Handle a packet delivered locally (via DeliverLocal).

Returns actions for the driver to dispatch. The dest_hash is the packet’s destination_hash field. raw is the full packet bytes. packet_hash is the SHA-256 hash.

Prepare a best-effort direct Link packet and report admission failures.

Source

pub fn identify( &self, link_id: &LinkId, identity: &Identity, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>

Send an identify message on a link (initiator reveals identity to responder).

Tear down a link.

Tear down all managed links.

Source

pub fn tick(&mut self, rng: &mut dyn Rng) -> Vec<LinkManagerAction>

Periodic tick: check keepalive, stale, timeouts for all links.

Check if a destination hash is a known link_id managed by this manager.

Get the state of a link.

Get the RTT of a link.

Update the RTT of a link (e.g., after path redirect to a direct connection).

Reset the inbound timer for a link (e.g., after path redirect).

Update the MTU of a link (e.g., after path redirect to a different interface).

Get the number of tracked links in any state.

Get the number of established, active links.

Source

pub fn resource_transfer_count(&self) -> usize

Get the number of active resource transfers across all links.

Source

pub fn cancel_all_resources( &mut self, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>

Cancel all active resource transfers and return the generated actions.

Get information about all active links.

Source

pub fn record_outbound_packet(&mut self, packet: &RawPacket)

Account a packed outbound action at the single driver dispatch point. LINKREQUEST is accounted when its engine is created since its wire destination is not the resulting link ID.

Source

pub fn resource_entries(&self) -> Vec<ResourceInfoEntry>

Get information about all active resource transfers.

Trait Implementations§

Source§

impl Default for LinkManager

Source§

fn default() -> Self

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> InterfaceConfigData for T
where T: Send + 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

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

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, !>

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.