Skip to main content

RnsNode

Struct RnsNode 

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

A running RNS node.

Implementations§

Source§

impl RnsNode

Source

pub fn from_config( config_path: Option<&Path>, callbacks: Box<dyn Callbacks>, ) -> Result<Self>

Start the node from a config file path. If config_path is None, uses ~/.reticulum/.

Source

pub fn from_private_config( config_dir: &Path, state_dir: &Path, underlay_mark: Option<u32>, callbacks: Box<dyn Callbacks>, ) -> Result<Self>

Start an application-private node from a dedicated configuration and state root.

Private nodes never expose the shared-instance or management servers, never load hooks, fail on unsupported/malformed enabled interfaces, and force runtime interface failures to stop startup. underlay_mark overrides the value in the Reticulum configuration.

Source

pub fn start(config: NodeConfig, callbacks: Box<dyn Callbacks>) -> Result<Self>

Start the node. Connects all interfaces, starts driver and timer threads.

Source

pub fn query(&self, request: QueryRequest) -> Result<QueryResponse, SendError>

Query the driver for state information.

Snapshot active Link metadata, including the negotiated direct-data MDU.

Source

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

Return the slowest positive bitrate among currently registered interfaces.

Returns Ok(None) when no registered interface advertises a usable bitrate.

Source

pub fn medium_path_timeout(&self) -> Result<f64, SendError>

Return the adaptive medium path timeout advertised by the transport engine.

The estimate covers a full MTU round trip on the slowest registered positive-bitrate interface plus the per-hop allowance, or is zero when no usable bitrate is known.

Source

pub fn begin_drain(&self, timeout: Duration) -> Result<(), SendError>

Enter drain mode and stop admitting new work.

Source

pub fn drain_status(&self) -> Result<DrainStatus, SendError>

Query current drain/lifecycle status.

Source

pub fn send_raw( &self, raw: Vec<u8>, dest_type: u8, attached_interface: Option<InterfaceId>, ) -> Result<(), SendError>

Send a raw outbound packet.

Source

pub fn register_destination( &self, dest_hash: [u8; 16], dest_type: u8, ) -> Result<(), SendError>

Register a local destination with the transport engine.

Source

pub fn deregister_destination( &self, dest_hash: [u8; 16], ) -> Result<(), SendError>

Deregister a local destination.

Deregister a link destination (stop accepting incoming links).

Register a link destination that can accept incoming links.

dest_hash: the destination hash sig_prv_bytes: Ed25519 private signing key (32 bytes) sig_pub_bytes: Ed25519 public signing key (32 bytes)

Register a link destination with an optional maximum accepted request size.

Source

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

Register a request handler for a given path on established links.

Source

pub fn register_request_handler_response<F>( &self, path: &str, allowed_list: Option<Vec<[u8; 16]>>, handler: F, ) -> Result<(), SendError>
where F: Fn([u8; 16], &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>( &self, path: &str, allowed_list: Option<Vec<[u8; 16]>>, handler: F, ) -> Result<(), SendError>
where F: Fn([u8; 16], &str, [u8; 16], &[u8], Option<&([u8; 16], [u8; 64])>) + Send + 'static,

Register a request handler whose response is completed asynchronously with RnsNode::send_deferred_response.

Source

pub fn send_deferred_response( &self, link_id: [u8; 16], request_id: [u8; 16], data: Vec<u8>, ) -> Result<(), SendError>

Complete a request accepted by a deferred request handler.

Create an outbound link to a destination.

Returns the link_id on success.

Source

pub fn send_request( &self, link_id: [u8; 16], path: &str, data: &[u8], ) -> Result<(), SendError>

Send a request on an established link.

Source

pub fn send_request_with_max_response_size( &self, link_id: [u8; 16], path: &str, data: &[u8], max_response_size: Option<usize>, ) -> Result<(), SendError>

Send a request with an optional maximum accepted response size.

Identify on a link (reveal identity to remote peer).

Tear down a link.

Source

pub fn send_resource( &self, link_id: [u8; 16], data: Vec<u8>, metadata: Option<Vec<u8>>, ) -> Result<(), SendError>

Send a resource on an established link.

Source

pub fn send_resource_with_auto_compress( &self, link_id: [u8; 16], data: Vec<u8>, metadata: Option<Vec<u8>>, auto_compress: bool, ) -> Result<(), SendError>

Send a resource on an established link, controlling automatic compression.

Source

pub fn send_resource_reader<R: Read + Send + 'static>( &self, link_id: [u8; 16], reader: R, declared_length: u64, metadata: Option<Vec<u8>>, auto_compress: bool, ) -> Result<ResourceTransferId, SendError>

Send a Resource from a sequential reader without retaining the full logical payload in memory.

Source

pub fn send_resource_file( &self, link_id: [u8; 16], path: impl AsRef<Path>, metadata: Option<Vec<u8>>, auto_compress: bool, ) -> Result<ResourceTransferId>

Send a file as a bounded-memory streaming Resource.

Source

pub fn set_resource_receive_mode( &self, link_id: [u8; 16], mode: ResourceReceiveMode, ) -> Result<(), SendError>

Select delivery policy for independent incoming Resources on a link.

Source

pub fn set_resource_strategy( &self, link_id: [u8; 16], strategy: u8, ) -> Result<(), SendError>

Set the resource acceptance strategy for a link.

0 = AcceptNone, 1 = AcceptAll, 2 = AcceptApp

Source

pub fn accept_resource( &self, link_id: [u8; 16], resource_hash: Vec<u8>, accept: bool, ) -> Result<(), SendError>

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

Source

pub fn send_channel_message( &self, link_id: [u8; 16], msgtype: u16, payload: Vec<u8>, ) -> Result<(), SendError>

Send a channel message on a link (compatibility API).

Source

pub fn try_send_channel_message( &self, link_id: [u8; 16], msgtype: u16, payload: Vec<u8>, ) -> Result<(), ChannelSendError>

Attempt to enqueue a channel message, preserving temporary backpressure. A NotReady result means no sequence was reserved; callers can retry the same payload when capacity is available. Other failures are terminal.

Source

pub fn propose_direct_connect(&self, link_id: [u8; 16]) -> Result<(), SendError>

Propose a direct P2P connection to a peer via NAT hole punching.

The link must be active and connected through a backbone node. If successful, a direct UDP connection will be established, bypassing the backbone.

Source

pub fn set_direct_connect_policy( &self, policy: HolePunchPolicy, ) -> Result<(), SendError>

Set the policy for handling incoming direct-connect proposals.

Send data on a link with a given context.

Admit a best-effort direct Link datagram without blocking on queue space.

Success means the driver accepted and encoded the packet. It does not imply remote delivery, acknowledgement, or interface transmission.

Source

pub fn announce( &self, dest: &Destination, identity: &Identity, app_data: Option<&[u8]>, ) -> Result<(), SendError>

Build and broadcast an announce for a destination.

The identity is used to sign the announce. Must be the identity that owns the destination (i.e. identity.hash() matches dest.identity_hash).

Source

pub fn send_packet( &self, dest: &Destination, data: &[u8], ) -> Result<PacketHash, SendError>

Send an encrypted (SINGLE) or plaintext (PLAIN) packet to a destination.

For SINGLE destinations, dest.public_key must be set (OUT direction). Returns the packet hash for proof tracking.

Source

pub fn register_destination_with_proof( &self, dest: &Destination, signing_key: Option<[u8; 64]>, ) -> Result<(), SendError>

Register a destination with the transport engine and set its proof strategy.

signing_key is the full 64-byte identity private key (X25519 32 bytes + Ed25519 32 bytes), needed for ProveAll/ProveApp to sign proof packets.

Source

pub fn request_path(&self, dest_hash: &DestHash) -> Result<(), SendError>

Request a path to a destination from the network.

Source

pub fn has_path(&self, dest_hash: &DestHash) -> Result<bool, SendError>

Check if a path exists to a destination (synchronous query).

Source

pub fn hops_to(&self, dest_hash: &DestHash) -> Result<Option<u8>, SendError>

Get hop count to a destination (synchronous query).

Source

pub fn recall_identity( &self, dest_hash: &DestHash, ) -> Result<Option<AnnouncedIdentity>, SendError>

Recall the identity information for a previously announced destination.

Source

pub fn known_destinations( &self, ) -> Result<Vec<KnownDestinationEntry>, SendError>

List known destinations and their lifecycle state.

Source

pub fn retain_known_destination( &self, dest_hash: &DestHash, ) -> Result<bool, SendError>

Mark a known destination as retained.

Source

pub fn retain_identity( &self, identity_hash: &IdentityHash, ) -> Result<bool, SendError>

Mark all known destinations announced by an identity as retained.

Source

pub fn unretain_known_destination( &self, dest_hash: &DestHash, ) -> Result<bool, SendError>

Clear the retained flag on a known destination.

Source

pub fn mark_known_destination_used( &self, dest_hash: &DestHash, ) -> Result<bool, SendError>

Mark a known destination as used.

Source

pub fn load_hook( &self, name: String, wasm_bytes: Vec<u8>, attach_point: String, priority: i32, ) -> Result<Result<(), String>, SendError>

Load an in-memory WASM hook at runtime.

Source

pub fn load_hook_file( &self, name: String, path: String, hook_type: String, attach_point: String, priority: i32, ) -> Result<Result<(), String>, SendError>

Load a hook from a server-local filesystem path at runtime.

Source

pub fn load_builtin_hook( &self, name: String, builtin_id: String, attach_point: String, priority: i32, ) -> Result<Result<(), String>, SendError>

Load a registered built-in hook at runtime.

Source

pub fn unload_hook( &self, name: String, attach_point: String, ) -> Result<Result<(), String>, SendError>

Unload a hook at runtime.

Source

pub fn reload_hook( &self, name: String, attach_point: String, wasm_bytes: Vec<u8>, ) -> Result<Result<(), String>, SendError>

Reload an in-memory WASM hook at runtime (detach + recompile + reattach with same priority).

Source

pub fn reload_hook_file( &self, name: String, attach_point: String, path: String, hook_type: String, ) -> Result<Result<(), String>, SendError>

Reload a hook from a server-local filesystem path at runtime.

Source

pub fn reload_builtin_hook( &self, name: String, attach_point: String, builtin_id: String, ) -> Result<Result<(), String>, SendError>

Reload a registered built-in hook at runtime.

Source

pub fn set_hook_enabled( &self, name: String, attach_point: String, enabled: bool, ) -> Result<Result<(), String>, SendError>

Enable or disable a loaded hook at runtime.

Source

pub fn set_hook_priority( &self, name: String, attach_point: String, priority: i32, ) -> Result<Result<(), String>, SendError>

Update the priority of a loaded hook at runtime.

Source

pub fn list_hooks(&self) -> Result<Vec<HookInfo>, SendError>

List all loaded hooks.

Source

pub fn event_sender(&self) -> &EventSender

Get the event sender for direct event injection.

Source

pub fn set_tick_interval(&self, ms: u64) -> u64

Set the tick interval in milliseconds. Default is 1000 (1 second). Changes take effect on the next tick cycle. Values are clamped to the range 100..=10000. Returns the actual stored value (which may differ from ms if clamped).

Source

pub fn tick_interval(&self) -> u64

Get the current tick interval in milliseconds.

Source

pub fn shutdown(self)

Shut down the node. Blocks until the driver thread exits.

Source§

impl RnsNode

Source

pub fn connect_shared( config: SharedClientConfig, callbacks: Box<dyn Callbacks>, ) -> Result<Self>

Connect to an existing shared instance as a client.

The client runs transport_enabled: false — it does no routing, but can register destinations and send/receive packets through the daemon.

Source

pub fn connect_shared_from_config( config_path: Option<&Path>, callbacks: Box<dyn Callbacks>, ) -> Result<Self>

Connect to a shared instance, with config loaded from a config directory.

Reads the config file to determine instance_name and ports.

Trait Implementations§

Source§

impl Drop for RnsNode

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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.