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