pub struct RnsNode { /* private fields */ }Expand description
A running RNS node.
Implementations§
Source§impl RnsNode
impl RnsNode
Sourcepub fn from_config(
config_path: Option<&Path>,
callbacks: Box<dyn Callbacks>,
) -> Result<Self>
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/.
Sourcepub fn start(config: NodeConfig, callbacks: Box<dyn Callbacks>) -> Result<Self>
pub fn start(config: NodeConfig, callbacks: Box<dyn Callbacks>) -> Result<Self>
Start the node. Connects all interfaces, starts driver and timer threads.
Sourcepub fn query(&self, request: QueryRequest) -> Result<QueryResponse, SendError>
pub fn query(&self, request: QueryRequest) -> Result<QueryResponse, SendError>
Query the driver for state information.
Sourcepub fn send_raw(
&self,
raw: Vec<u8>,
dest_type: u8,
attached_interface: Option<InterfaceId>,
) -> Result<(), SendError>
pub fn send_raw( &self, raw: Vec<u8>, dest_type: u8, attached_interface: Option<InterfaceId>, ) -> Result<(), SendError>
Send a raw outbound packet.
Sourcepub fn register_destination(
&self,
dest_hash: [u8; 16],
dest_type: u8,
) -> Result<(), SendError>
pub fn register_destination( &self, dest_hash: [u8; 16], dest_type: u8, ) -> Result<(), SendError>
Register a local destination with the transport engine.
Sourcepub fn deregister_destination(
&self,
dest_hash: [u8; 16],
) -> Result<(), SendError>
pub fn deregister_destination( &self, dest_hash: [u8; 16], ) -> Result<(), SendError>
Deregister a local destination.
Sourcepub fn deregister_link_destination(
&self,
dest_hash: [u8; 16],
) -> Result<(), SendError>
pub fn deregister_link_destination( &self, dest_hash: [u8; 16], ) -> Result<(), SendError>
Deregister a link destination (stop accepting incoming links).
Sourcepub fn register_link_destination(
&self,
dest_hash: [u8; 16],
sig_prv_bytes: [u8; 32],
sig_pub_bytes: [u8; 32],
resource_strategy: u8,
) -> Result<(), SendError>
pub fn register_link_destination( &self, dest_hash: [u8; 16], sig_prv_bytes: [u8; 32], sig_pub_bytes: [u8; 32], resource_strategy: u8, ) -> Result<(), SendError>
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)
Sourcepub fn register_request_handler<F>(
&self,
path: &str,
allowed_list: Option<Vec<[u8; 16]>>,
handler: F,
) -> Result<(), SendError>
pub fn register_request_handler<F>( &self, path: &str, allowed_list: Option<Vec<[u8; 16]>>, handler: F, ) -> Result<(), SendError>
Register a request handler for a given path on established links.
Sourcepub fn create_link(
&self,
dest_hash: [u8; 16],
dest_sig_pub_bytes: [u8; 32],
) -> Result<[u8; 16], SendError>
pub fn create_link( &self, dest_hash: [u8; 16], dest_sig_pub_bytes: [u8; 32], ) -> Result<[u8; 16], SendError>
Create an outbound link to a destination.
Returns the link_id on success.
Sourcepub fn send_request(
&self,
link_id: [u8; 16],
path: &str,
data: &[u8],
) -> Result<(), SendError>
pub fn send_request( &self, link_id: [u8; 16], path: &str, data: &[u8], ) -> Result<(), SendError>
Send a request on an established link.
Sourcepub fn identify_on_link(
&self,
link_id: [u8; 16],
identity_prv_key: [u8; 64],
) -> Result<(), SendError>
pub fn identify_on_link( &self, link_id: [u8; 16], identity_prv_key: [u8; 64], ) -> Result<(), SendError>
Identify on a link (reveal identity to remote peer).
Sourcepub fn send_resource(
&self,
link_id: [u8; 16],
data: Vec<u8>,
metadata: Option<Vec<u8>>,
) -> Result<(), SendError>
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.
Sourcepub fn set_resource_strategy(
&self,
link_id: [u8; 16],
strategy: u8,
) -> Result<(), SendError>
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
Sourcepub fn accept_resource(
&self,
link_id: [u8; 16],
resource_hash: Vec<u8>,
accept: bool,
) -> Result<(), SendError>
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).
Sourcepub fn send_channel_message(
&self,
link_id: [u8; 16],
msgtype: u16,
payload: Vec<u8>,
) -> Result<(), SendError>
pub fn send_channel_message( &self, link_id: [u8; 16], msgtype: u16, payload: Vec<u8>, ) -> Result<(), SendError>
Send a channel message on a link.
Sourcepub fn propose_direct_connect(&self, link_id: [u8; 16]) -> Result<(), SendError>
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.
Sourcepub fn set_direct_connect_policy(
&self,
policy: HolePunchPolicy,
) -> Result<(), SendError>
pub fn set_direct_connect_policy( &self, policy: HolePunchPolicy, ) -> Result<(), SendError>
Set the policy for handling incoming direct-connect proposals.
Sourcepub fn send_on_link(
&self,
link_id: [u8; 16],
data: Vec<u8>,
context: u8,
) -> Result<(), SendError>
pub fn send_on_link( &self, link_id: [u8; 16], data: Vec<u8>, context: u8, ) -> Result<(), SendError>
Send data on a link with a given context.
Sourcepub fn announce(
&self,
dest: &Destination,
identity: &Identity,
app_data: Option<&[u8]>,
) -> Result<(), SendError>
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).
Sourcepub fn send_packet(
&self,
dest: &Destination,
data: &[u8],
) -> Result<PacketHash, SendError>
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.
Sourcepub fn register_destination_with_proof(
&self,
dest: &Destination,
signing_key: Option<[u8; 64]>,
) -> Result<(), SendError>
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.
Sourcepub fn request_path(&self, dest_hash: &DestHash) -> Result<(), SendError>
pub fn request_path(&self, dest_hash: &DestHash) -> Result<(), SendError>
Request a path to a destination from the network.
Sourcepub fn has_path(&self, dest_hash: &DestHash) -> Result<bool, SendError>
pub fn has_path(&self, dest_hash: &DestHash) -> Result<bool, SendError>
Check if a path exists to a destination (synchronous query).
Sourcepub fn hops_to(&self, dest_hash: &DestHash) -> Result<Option<u8>, SendError>
pub fn hops_to(&self, dest_hash: &DestHash) -> Result<Option<u8>, SendError>
Get hop count to a destination (synchronous query).
Sourcepub fn recall_identity(
&self,
dest_hash: &DestHash,
) -> Result<Option<AnnouncedIdentity>, SendError>
pub fn recall_identity( &self, dest_hash: &DestHash, ) -> Result<Option<AnnouncedIdentity>, SendError>
Recall the identity information for a previously announced destination.
Sourcepub fn load_hook(
&self,
name: String,
wasm_bytes: Vec<u8>,
attach_point: String,
priority: i32,
) -> Result<Result<(), String>, SendError>
pub fn load_hook( &self, name: String, wasm_bytes: Vec<u8>, attach_point: String, priority: i32, ) -> Result<Result<(), String>, SendError>
Load a WASM hook at runtime.
Sourcepub fn unload_hook(
&self,
name: String,
attach_point: String,
) -> Result<Result<(), String>, SendError>
pub fn unload_hook( &self, name: String, attach_point: String, ) -> Result<Result<(), String>, SendError>
Unload a WASM hook at runtime.
Sourcepub fn reload_hook(
&self,
name: String,
attach_point: String,
wasm_bytes: Vec<u8>,
) -> Result<Result<(), String>, SendError>
pub fn reload_hook( &self, name: String, attach_point: String, wasm_bytes: Vec<u8>, ) -> Result<Result<(), String>, SendError>
Reload a WASM hook at runtime (detach + recompile + reattach with same priority).
Sourcepub fn event_sender(&self) -> &EventSender
pub fn event_sender(&self) -> &EventSender
Get the event sender for direct event injection.
Sourcepub fn set_tick_interval(&self, ms: u64) -> u64
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).
Sourcepub fn tick_interval(&self) -> u64
pub fn tick_interval(&self) -> u64
Get the current tick interval in milliseconds.
Source§impl RnsNode
impl RnsNode
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.
Connect to a shared instance, with config loaded from a config directory.
Reads the config file to determine instance_name and ports.
Auto Trait Implementations§
impl Freeze for RnsNode
impl !RefUnwindSafe for RnsNode
impl Send for RnsNode
impl Sync for RnsNode
impl Unpin for RnsNode
impl UnsafeUnpin for RnsNode
impl !UnwindSafe for RnsNode
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> 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