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