Skip to main content

rns_net/
lib.rs

1//! rns-net: Network node for Reticulum.
2//!
3//! Drives `rns-core::TransportEngine` with real TCP/UDP sockets and threads.
4//! Reads standard Python RNS config files, opens TCP server/client, UDP, and
5//! Local interfaces, persists identity and known destinations.
6
7#[cfg(feature = "hooks")]
8extern crate rns_hooks_crate as rns_hooks;
9
10pub mod common;
11pub mod event;
12pub mod hdlc;
13pub mod kiss;
14pub mod link_send;
15pub mod logging;
16pub mod rnode_kiss;
17pub use common::time;
18pub mod driver;
19pub mod interface;
20pub mod node;
21pub use common::config;
22pub mod announce_cache;
23pub mod ifac;
24pub mod md5;
25pub mod pickle;
26/// Process-global live profiling.
27///
28/// Unlike Python's package imports, Rust module declarations are resolved
29/// statically and do not execute in source order. The profiler can therefore
30/// stay in the normal crate module graph without a late-import workaround for
31/// circular initialization.
32pub mod profiling;
33#[cfg(feature = "iface-local")]
34pub mod remote_management;
35pub mod resource;
36pub mod rpc;
37pub mod serial;
38pub mod storage;
39pub use common::compressor;
40pub use common::link_manager;
41pub mod management;
42#[cfg(feature = "iface-local")]
43pub mod shared_client;
44pub use common::destination;
45pub mod discovery;
46pub mod holepunch;
47#[cfg(feature = "hooks")]
48pub mod provider_bridge;
49
50pub use config::RnsConfig;
51pub use destination::{AnnouncedIdentity, Destination, GroupKeyError};
52#[cfg(feature = "iface-backbone")]
53pub use driver::BackbonePeerPoolSettings;
54pub use driver::{AnnounceRateDefaults, Callbacks};
55pub use event::{
56    BackbonePeerHookEvent, BackbonePeerPoolMemberStatus, BackbonePeerPoolStatus,
57    BackbonePeerStateEntry, BlackholeInfo, Event, HookInfo, InterfaceStatsResponse,
58    LinkDatagramError, LinkInfoEntry, LocalDestinationEntry, NextHopResponse, PathTableEntry,
59    QueryRequest, QueryResponse, RateTableEntry, ResourceInfoEntry, RuntimeConfigApplyMode,
60    RuntimeConfigEntry, RuntimeConfigError, RuntimeConfigErrorCode, RuntimeConfigSource,
61    RuntimeConfigValue, SingleInterfaceStat, TrafficDetail,
62};
63pub use ifac::IfacState;
64#[cfg(feature = "iface-auto")]
65pub use interface::auto::{AutoConfig, AutoFactory};
66#[cfg(feature = "iface-ax25-kiss")]
67pub use interface::ax25_kiss::{
68    decode_ui_frame as decode_ax25_ui_frame, encode_ui_frame as encode_ax25_ui_frame,
69    validate_address as validate_ax25_address, Ax25KissFactory,
70};
71#[cfg(feature = "iface-backbone")]
72pub use interface::backbone::{
73    BackboneClientConfig, BackboneClientInterfaceFactory, BackboneConfig, BackboneInterfaceFactory,
74};
75#[cfg(feature = "iface-i2p")]
76pub use interface::i2p::{I2pConfig, I2pFactory};
77#[cfg(feature = "iface-ax25-kiss")]
78pub use interface::kiss_iface::Ax25Address;
79#[cfg(feature = "iface-kiss")]
80pub use interface::kiss_iface::{KissFactory, KissIfaceConfig};
81#[cfg(feature = "iface-local")]
82pub use interface::local::{
83    LocalClientConfig, LocalClientFactory, LocalServerConfig, LocalServerFactory,
84};
85#[cfg(feature = "iface-pipe")]
86pub use interface::pipe::{PipeConfig, PipeFactory};
87pub use interface::registry::InterfaceRegistry;
88#[cfg(feature = "iface-rnode")]
89pub use interface::rnode::{RNodeConfig, RNodeFactory, RNodeMultiFactory, RNodeSubConfig};
90#[cfg(feature = "iface-serial")]
91pub use interface::serial_iface::{SerialFactory, SerialIfaceConfig};
92#[cfg(feature = "iface-tcp")]
93pub use interface::tcp::{TcpClientConfig, TcpClientFactory};
94#[cfg(feature = "iface-tcp")]
95pub use interface::tcp_server::{TcpServerConfig, TcpServerFactory};
96#[cfg(feature = "iface-udp")]
97pub use interface::udp::{UdpConfig, UdpFactory};
98#[cfg(all(feature = "iface-weave", target_os = "linux"))]
99pub use interface::weave::{
100    parse_device_frame as parse_weave_device_frame, WdclFrame, WeaveConfig, WeaveFactory,
101    WeaveInput, WeaveLogFrame, WeavePeerState, WeaveState,
102};
103pub use interface::{install_socket_protector, SocketProtector, SocketProtectorGuard};
104pub use interface::{
105    InterfaceConfigData, InterfaceFactory, StartContext, StartResult, SubInterface,
106};
107pub use link_manager::{LinkManager, LinkManagerAction, RequestFailure, RequestResponse};
108pub use link_send::{LinkSendError, LinkSendReceipt};
109pub use link_send::{
110    LinkSendError as TransmissionError, LinkSendReceipt as TransmissionReceipt, PacketSendReceipt,
111};
112pub use management::ManagementConfig;
113pub use node::{ChannelSendError, IfacConfig, InterfaceConfig, NodeConfig, RnsNode, SendError};
114#[cfg(feature = "hooks")]
115pub use provider_bridge::{
116    HookProviderEventEnvelope, OverflowPolicy, ProviderBridge, ProviderBridgeConfig,
117    ProviderEnvelope, ProviderMessage,
118};
119pub use resource::{
120    ReceivedResourceFile, ResourceReceiveMode, ResourceTransferError, ResourceTransferId,
121};
122pub use rpc::{RpcAddr, RpcClient, RpcServer};
123pub use serial::Parity;
124#[cfg(feature = "iface-local")]
125pub use shared_client::SharedClientConfig;
126pub use storage::{
127    FsRatchetStore, KnownDestination, RatchetCleanupStats, RatchetEntry, RatchetStore, StoragePaths,
128};
129
130// Re-export commonly used types from rns-core
131pub use rns_core::constants::{
132    MODE_ACCESS_POINT, MODE_BOUNDARY, MODE_FULL, MODE_GATEWAY, MODE_INTERNAL, MODE_POINT_TO_POINT,
133    MODE_ROAMING,
134};
135pub use rns_core::link::TeardownReason;
136pub use rns_core::transport::types::InterfaceId;
137pub use rns_core::types::{
138    DestHash, DestinationType, Direction, IdentityHash, LinkId, PacketHash, ProofStrategy,
139};
140
141#[cfg(test)]
142mod test_support;
143
144#[cfg(test)]
145mod module_initialization_tests {
146    #[test]
147    fn profiler_is_available_from_the_crate_root_without_late_imports() {
148        let sample = crate::profiling::profile("entry117.crate-root");
149        drop(sample);
150        assert_eq!(
151            crate::profiling::results()["entry117.crate-root"]
152                .stats_all
153                .count,
154            1
155        );
156    }
157}