pub struct LinkManager { /* private fields */ }Expand description
Manages multiple links, link destinations, and request/response.
Implementations§
Source§impl LinkManager
impl LinkManager
Sourcepub fn register_management_path(&mut self, path_hash: [u8; 16])
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).
Sourcepub fn get_derived_key(&self, link_id: &LinkId) -> Option<Vec<u8>>
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).
Sourcepub fn register_link_destination(
&mut self,
dest_hash: [u8; 16],
sig_prv: Ed25519PrivateKey,
sig_pub_bytes: [u8; 32],
resource_strategy: ResourceStrategy,
)
pub fn register_link_destination( &mut self, dest_hash: [u8; 16], sig_prv: Ed25519PrivateKey, sig_pub_bytes: [u8; 32], resource_strategy: ResourceStrategy, )
Register a destination that can accept incoming links.
Sourcepub fn deregister_link_destination(&mut self, dest_hash: &[u8; 16])
pub fn deregister_link_destination(&mut self, dest_hash: &[u8; 16])
Deregister a link destination.
Sourcepub fn register_request_handler<F>(
&mut self,
path: &str,
allowed_list: Option<Vec<[u8; 16]>>,
handler: F,
)
pub fn register_request_handler<F>( &mut self, path: &str, allowed_list: Option<Vec<[u8; 16]>>, handler: F, )
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
Sourcepub fn create_link(
&mut self,
dest_hash: &[u8; 16],
dest_sig_pub_bytes: &[u8; 32],
hops: u8,
mtu: u32,
rng: &mut dyn Rng,
) -> (LinkId, Vec<LinkManagerAction>)
pub fn create_link( &mut self, dest_hash: &[u8; 16], dest_sig_pub_bytes: &[u8; 32], hops: u8, mtu: u32, rng: &mut dyn Rng, ) -> (LinkId, Vec<LinkManagerAction>)
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.
Sourcepub 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>
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.
Sourcepub fn send_management_response(
&self,
link_id: &LinkId,
request_id: &[u8; 16],
response_data: &[u8],
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
pub fn send_management_response( &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.
Sourcepub fn send_request(
&self,
link_id: &LinkId,
path: &str,
data: &[u8],
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
pub fn send_request( &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.
Sourcepub fn send_on_link(
&self,
link_id: &LinkId,
plaintext: &[u8],
context: u8,
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
pub fn send_on_link( &self, link_id: &LinkId, plaintext: &[u8], context: u8, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>
Send encrypted data on a link with a given context.
Sourcepub fn identify(
&self,
link_id: &LinkId,
identity: &Identity,
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
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).
Sourcepub fn teardown_link(&mut self, link_id: &LinkId) -> Vec<LinkManagerAction>
pub fn teardown_link(&mut self, link_id: &LinkId) -> Vec<LinkManagerAction>
Tear down a link.
Sourcepub fn teardown_all_links(&mut self) -> Vec<LinkManagerAction>
pub fn teardown_all_links(&mut self) -> Vec<LinkManagerAction>
Tear down all managed links.
Sourcepub fn accept_resource(
&mut self,
link_id: &LinkId,
resource_hash: &[u8],
accept: bool,
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
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).
Sourcepub fn send_resource(
&mut self,
link_id: &LinkId,
data: &[u8],
metadata: Option<&[u8]>,
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
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.
Sourcepub fn set_resource_strategy(
&mut self,
link_id: &LinkId,
strategy: ResourceStrategy,
)
pub fn set_resource_strategy( &mut self, link_id: &LinkId, strategy: ResourceStrategy, )
Set the resource acceptance strategy for a link.
Sourcepub fn flush_channel_tx(&mut self, link_id: &LinkId)
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.
Sourcepub fn send_channel_message(
&mut self,
link_id: &LinkId,
msgtype: u16,
payload: &[u8],
rng: &mut dyn Rng,
) -> Result<Vec<LinkManagerAction>, String>
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.
Sourcepub fn tick(&mut self, rng: &mut dyn Rng) -> Vec<LinkManagerAction>
pub fn tick(&mut self, rng: &mut dyn Rng) -> Vec<LinkManagerAction>
Periodic tick: check keepalive, stale, timeouts for all links.
Sourcepub fn is_link_destination(&self, dest_hash: &[u8; 16]) -> bool
pub fn is_link_destination(&self, dest_hash: &[u8; 16]) -> bool
Check if a destination hash is a known link_id managed by this manager.
Sourcepub fn link_state(&self, link_id: &LinkId) -> Option<LinkState>
pub fn link_state(&self, link_id: &LinkId) -> Option<LinkState>
Get the state of a link.
Sourcepub fn set_link_rtt(&mut self, link_id: &LinkId, rtt: f64)
pub fn set_link_rtt(&mut self, link_id: &LinkId, rtt: f64)
Update the RTT of a link (e.g., after path redirect to a direct connection).
Sourcepub fn record_link_inbound(&mut self, link_id: &LinkId)
pub fn record_link_inbound(&mut self, link_id: &LinkId)
Reset the inbound timer for a link (e.g., after path redirect).
Sourcepub fn set_link_mtu(&mut self, link_id: &LinkId, mtu: u32)
pub fn set_link_mtu(&mut self, link_id: &LinkId, mtu: u32)
Update the MTU of a link (e.g., after path redirect to a different interface).
Sourcepub fn link_count(&self) -> usize
pub fn link_count(&self) -> usize
Get the number of active links.
Sourcepub fn resource_transfer_count(&self) -> usize
pub fn resource_transfer_count(&self) -> usize
Get the number of active resource transfers across all links.
Sourcepub fn cancel_all_resources(
&mut self,
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
pub fn cancel_all_resources( &mut self, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>
Cancel all active resource transfers and return the generated actions.
Sourcepub fn link_entries(&self) -> Vec<LinkInfoEntry>
pub fn link_entries(&self) -> Vec<LinkInfoEntry>
Get information about all active links.
Sourcepub fn resource_entries(&self) -> Vec<ResourceInfoEntry>
pub fn resource_entries(&self) -> Vec<ResourceInfoEntry>
Get information about all active resource transfers.
Auto Trait Implementations§
impl Freeze for LinkManager
impl !RefUnwindSafe for LinkManager
impl Send for LinkManager
impl !Sync for LinkManager
impl Unpin for LinkManager
impl UnsafeUnpin for LinkManager
impl !UnwindSafe for LinkManager
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> InterfaceConfigData for Twhere
T: Send + 'static,
impl<T> InterfaceConfigData for Twhere
T: Send + 'static,
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