Skip to main content

TransportEngine

Struct TransportEngine 

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

The core transport/routing engine.

Maintains routing tables and processes packets without performing any I/O. Returns Vec<TransportAction> that the caller must execute.

Implementations§

Source§

impl TransportEngine

Source

pub fn handle_path_request( &mut self, data: &[u8], interface_id: InterfaceId, now: f64, ) -> Vec<TransportAction>

Source§

impl TransportEngine

Source

pub fn persistence_snapshot(&self) -> TransportStateSnapshot

Copy the restart-relevant portion of transport state.

Source

pub fn restore_persistence_snapshot<F>( &mut self, snapshot: TransportStateSnapshot, now: f64, announce_lookup: F, ) -> RestoreStats
where F: FnMut(&[u8; 32]) -> Option<Vec<u8>>,

Restore state after interfaces and the announce cache are available.

Source§

impl TransportEngine

Source

pub fn lowest_interface_bitrate(&self) -> Option<u64>

Return the slowest positive bitrate among registered interfaces.

Returns None when no registered interface advertises a usable bitrate.

Source

pub fn medium_path_timeout(&self) -> f64

Estimate a path-request round-trip timeout for the slowest medium.

The estimate covers two MTU transmissions at the slowest registered positive bitrate plus the per-hop link-establishment allowance. It is zero when no usable interface bitrate is known.

Source

pub fn path_table_entries( &self, ) -> impl Iterator<Item = (&[u8; 16], &PathEntry)>

Source

pub fn path_table_sets(&self) -> impl Iterator<Item = (&[u8; 16], &PathSet)>

Source

pub fn interface_count(&self) -> usize

Source

pub fn is_packet_filter_protocol_violation( &self, packet: &RawPacket, interface: InterfaceId, ) -> bool

Classify packet-filter rejections that are peer protocol violations.

Source

pub fn path_table_count(&self) -> usize

Source

pub fn announce_table_count(&self) -> usize

Source

pub fn reverse_table_count(&self) -> usize

Source

pub fn held_announces_count(&self) -> usize

Source

pub fn packet_hashlist_len(&self) -> usize

Source

pub fn announce_sig_cache_len(&self) -> usize

Source

pub fn rate_limiter_count(&self) -> usize

Source

pub fn blackholed_count(&self) -> usize

Source

pub fn tunnel_count(&self) -> usize

Source

pub fn discovery_pr_tags_count(&self) -> usize

Source

pub fn discovery_path_requests_count(&self) -> usize

Source

pub fn announce_queue_count(&self) -> usize

Source

pub fn nonempty_announce_queue_count(&self) -> usize

Source

pub fn queued_announce_count(&self) -> usize

Source

pub fn queued_announce_bytes(&self) -> usize

Source

pub fn announce_queue_interface_cap_drop_count(&self) -> u64

Source

pub fn local_destinations_count(&self) -> usize

Source

pub fn rate_limiter(&self) -> &AnnounceRateLimiter

Source

pub fn interface_info(&self, id: &InterfaceId) -> Option<&InterfaceInfo>

Source

pub fn redirect_path( &mut self, dest_hash: &[u8; 16], interface: InterfaceId, now: f64, )

Source

pub fn inject_path(&mut self, dest_hash: [u8; 16], entry: PathEntry)

Source

pub fn drop_path(&mut self, dest_hash: &[u8; 16]) -> bool

Source

pub fn drop_all_via(&mut self, transport_hash: &[u8; 16]) -> usize

Source

pub fn drop_paths_for_interface(&mut self, interface: InterfaceId) -> usize

Source

pub fn drop_reverse_for_interface(&mut self, interface: InterfaceId) -> usize

Source

pub fn drop_announce_queues(&mut self)

Source

pub fn void_queues(&mut self)

Source

pub fn identity_hash(&self) -> Option<&[u8; 16]>

Source

pub fn transport_enabled(&self) -> bool

Source

pub fn config(&self) -> &TransportConfig

Source

pub fn set_packet_hashlist_max_entries(&mut self, max_entries: usize)

Source

pub fn get_path_table(&self, max_hops: Option<u8>) -> Vec<PathTableRow> ⓘ

Source

pub fn get_rate_table(&self) -> Vec<RateTableRow> ⓘ

Source

pub fn get_blackholed(&self) -> Vec<([u8; 16], f64, f64, Option<String>)>

Source

pub fn active_destination_hashes(&self) -> BTreeSet<[u8; 16]>

Source

pub fn path_destination_cap_evict_count(&self) -> usize

Source

pub fn active_packet_hashes(&self) -> Vec<[u8; 32]>

Source

pub fn cull_rate_limiter( &mut self, active: &BTreeSet<[u8; 16]>, now: f64, ttl_secs: f64, ) -> usize

Source

pub fn update_interface_freq(&mut self, id: InterfaceId, ia_freq: f64)

Source

pub fn update_interface_freqs( &mut self, id: InterfaceId, ia_freq: f64, ip_freq: f64, op_freq: f64, op_samples: usize, )

Source

pub fn held_announce_count(&self, interface: &InterfaceId) -> usize

Source

pub fn burst_active(&self, interface: &InterfaceId) -> bool

Source

pub fn burst_activated(&self, interface: &InterfaceId) -> f64

Source

pub fn pr_burst_active(&self, interface: &InterfaceId) -> bool

Source

pub fn pr_burst_activated(&self, interface: &InterfaceId) -> f64

Source§

impl TransportEngine

Source

pub fn new(config: TransportConfig) -> Self

Source

pub fn register_interface(&mut self, info: InterfaceInfo)

Source

pub fn deregister_interface(&mut self, id: InterfaceId)

Source

pub fn register_destination(&mut self, dest_hash: [u8; 16], dest_type: u8)

Source

pub fn deregister_destination(&mut self, dest_hash: &[u8; 16])

Source

pub fn has_path(&self, dest_hash: &[u8; 16]) -> bool

Source

pub fn hops_to(&self, dest_hash: &[u8; 16]) -> Option<u8>

Source

pub fn next_hop(&self, dest_hash: &[u8; 16]) -> Option<[u8; 16]>

Source

pub fn next_hop_interface(&self, dest_hash: &[u8; 16]) -> Option<InterfaceId>

Source

pub fn mark_path_unresponsive( &mut self, dest_hash: &[u8; 16], receiving_interface: Option<InterfaceId>, )

Mark a path as unresponsive.

If receiving_interface is provided and points to a MODE_BOUNDARY interface, the marking is skipped — boundary interfaces must not poison path tables. (Python Transport.py: mark_path_unknown/unresponsive boundary exemption)

Source

pub fn mark_path_responsive(&mut self, dest_hash: &[u8; 16])

Source

pub fn path_is_unresponsive(&self, dest_hash: &[u8; 16]) -> bool

Source

pub fn expire_path(&mut self, dest_hash: &[u8; 16])

Return the destination whose unvalidated link route can be rebalanced by a mismatched-hop LRPROOF received from its recorded next hop.

Source

pub fn inbound_lrproof_rebalance_candidate( &self, raw: &[u8], receiving_interface: InterfaceId, ) -> Option<LrproofRebalanceCandidate>

Parse and filter an inbound frame before offering it for LRPROOF path rebalancing. The returned hops are the post-ingress metric used by the normal transport pipeline.

Validate a mismatched-hop LRPROOF and update the relay link route and destination path atomically enough for normal proof routing to resume.

The engine is exclusively borrowed for the whole operation, so the link and path mutations need neither separate path-table locks nor repeated map lookups. A path can legitimately be absent; that does not invalidate the authenticated link-route update.

Source

pub fn rebalance_destination_path_hops( &mut self, destination_hash: &[u8; 16], packet_hops: u8, ) -> bool

Update the current path metric after a terminus validates an LRPROOF.

Source

pub fn blackhole_identity( &mut self, identity_hash: [u8; 16], now: f64, duration_hours: Option<f64>, reason: Option<String>, )

Add an identity hash to the blackhole list.

identity_hash is the 16-byte identity hash to blackhole. now is the current Unix timestamp. If duration_hours is Some and greater than zero, the entry expires after that many hours; otherwise it does not expire. reason is optional descriptive text retained with the entry.

Source

pub fn unblackhole_identity(&mut self, identity_hash: &[u8; 16]) -> bool

Remove an identity hash from the blackhole list.

Returns true if an entry was removed, or false if the identity was not blackholed.

Source

pub fn is_blackholed(&self, identity_hash: &[u8; 16], now: f64) -> bool

Check if an identity hash is blackholed (and not expired).

Source

pub fn blackholed_entries( &self, ) -> impl Iterator<Item = (&[u8; 16], &BlackholeEntry)>

Get all blackhole entries (for queries).

Source

pub fn handle_tunnel( &mut self, tunnel_id: [u8; 32], interface: InterfaceId, now: f64, ) -> Vec<TransportAction>

Handle a validated tunnel synthesis — create new or reattach.

Returns actions for any restored paths.

Source

pub fn synthesize_tunnel( &self, identity: &Identity, interface_id: InterfaceId, rng: &mut dyn Rng, ) -> Vec<TransportAction>

Synthesize a tunnel on an interface.

identity: the transport identity (must have private key for signing) interface_id: which interface to send the synthesis on rng: random number generator

Returns TunnelSynthesize action to send the synthesis packet.

Source

pub fn void_tunnel_interface(&mut self, tunnel_id: &[u8; 32])

Void a tunnel’s interface connection (tunnel disconnected).

Source

pub fn tunnel_table(&self) -> &TunnelTable

Access the tunnel table for queries.

Source§

impl TransportEngine

Source

pub fn accepts_inbound_frame(&self, frame: InboundFrame<'_>) -> bool

Return whether an inbound frame passes parsing, hop, and packet filtering. This does not mutate deduplication or routing state.

Source

pub fn handle_inbound( &mut self, frame: InboundFrame<'_>, rng: &mut dyn Rng, ) -> Vec<TransportAction>

Process an inbound raw packet from a network interface.

Returns a list of actions for the caller to execute.

Source

pub fn handle_inbound_with_announce_queue( &mut self, frame: InboundFrame<'_>, rng: &mut dyn Rng, announce_queue: Option<&mut AnnounceVerifyQueue>, ) -> Vec<TransportAction>

Source

pub fn complete_verified_announce( &mut self, pending: PendingAnnounce, validated: ValidatedAnnounce, sig_cache_key: [u8; 32], now: f64, rng: &mut dyn Rng, ) -> Vec<TransportAction>

Source

pub fn clear_failed_verified_announce( &mut self, _sig_cache_key: [u8; 32], _now: f64, )

Source

pub fn announce_sig_cache_contains(&self, sig_cache_key: &[u8; 32]) -> bool

Source§

impl TransportEngine

Source

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

Periodic maintenance. Call regularly (e.g., every 250ms).

Source§

impl TransportEngine

Source

pub fn handle_outbound( &mut self, packet: &RawPacket, dest_type: u8, attached_interface: Option<InterfaceId>, now: f64, ) -> Vec<TransportAction>

Route an outbound packet.

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