rns-net 0.10.0

Network interfaces and node driver for the Reticulum Network Stack
Documentation
//! rns-net: Network node for Reticulum.
//!
//! Drives `rns-core::TransportEngine` with real TCP/UDP sockets and threads.
//! Reads standard Python RNS config files, opens TCP server/client, UDP, and
//! Local interfaces, persists identity and known destinations.

// Builds with only some of the built-in interfaces (rns-tun-android uses just
// TCP, UDP and Auto) leave parts of the shared socket, writer and event-loop
// machinery without callers. Silence the resulting unused-code lints for such
// partial builds only; the default build, which has every interface, keeps
// them and is what CI lints.
#![cfg_attr(
    not(all(
        feature = "iface-tcp",
        feature = "iface-udp",
        feature = "iface-local",
        feature = "iface-auto",
        feature = "iface-serial",
        feature = "iface-kiss",
        feature = "iface-ax25-kiss",
        feature = "iface-pipe",
        feature = "iface-rnode",
        feature = "iface-backbone",
        feature = "iface-i2p",
        feature = "iface-weave"
    )),
    allow(dead_code, unused_imports, unused_variables, unused_mut)
)]

#[cfg(feature = "hooks")]
extern crate rns_hooks_crate as rns_hooks;

pub mod common;
pub mod event;
pub mod hdlc;
pub mod kiss;
pub mod link_send;
pub mod logging;
pub mod rnode_kiss;
pub use common::time;
pub mod driver;
pub mod interface;
pub mod node;
pub use common::config;
pub mod announce_cache;
pub mod ifac;
pub mod local_ratchet;
pub mod md5;
mod packet_header;
pub mod pickle;
/// Process-global live profiling.
///
/// Unlike Python's package imports, Rust module declarations are resolved
/// statically and do not execute in source order. The profiler can therefore
/// stay in the normal crate module graph without a late-import workaround for
/// circular initialization.
pub mod profiling;
#[cfg(feature = "iface-local")]
pub mod remote_management;
pub mod resource;
pub mod rpc;
pub mod serial;
pub mod storage;
pub use common::compressor;
pub use common::link_manager;
pub use local_ratchet::{FileRatchetStore, LocalRatchetStore, LocalRatchets, MemoryRatchetStore};
pub mod management;
#[cfg(feature = "iface-local")]
pub mod shared_client;
pub use common::destination;
pub mod discovery;
pub mod holepunch;
#[cfg(feature = "hooks")]
pub mod provider_bridge;

pub use config::RnsConfig;
pub use destination::{AnnouncedIdentity, Destination, GroupKeyError};
#[cfg(feature = "iface-backbone")]
pub use driver::BackbonePeerPoolSettings;
pub use driver::{AnnounceRateDefaults, Callbacks};
pub use event::{
    BackbonePeerHookEvent, BackbonePeerPoolMemberStatus, BackbonePeerPoolStatus,
    BackbonePeerStateEntry, BlackholeInfo, Event, HookInfo, InterfaceStatsResponse,
    LinkDatagramError, LinkInfoEntry, LocalDestinationEntry, NextHopResponse, PathTableEntry,
    QueryRequest, QueryResponse, RateTableEntry, ResourceInfoEntry, RuntimeConfigApplyMode,
    RuntimeConfigEntry, RuntimeConfigError, RuntimeConfigErrorCode, RuntimeConfigSource,
    RuntimeConfigValue, SingleInterfaceStat, TrafficDetail,
};
pub use ifac::IfacState;
#[cfg(feature = "iface-auto")]
pub use interface::auto::{AutoConfig, AutoFactory};
#[cfg(feature = "iface-ax25-kiss")]
pub use interface::ax25_kiss::{
    decode_ui_frame as decode_ax25_ui_frame, encode_ui_frame as encode_ax25_ui_frame,
    validate_address as validate_ax25_address, Ax25KissFactory,
};
#[cfg(feature = "iface-backbone")]
pub use interface::backbone::{
    BackboneClientConfig, BackboneClientInterfaceFactory, BackboneConfig, BackboneInterfaceFactory,
};
#[cfg(feature = "iface-i2p")]
pub use interface::i2p::{I2pConfig, I2pFactory};
#[cfg(feature = "iface-ax25-kiss")]
pub use interface::kiss_iface::Ax25Address;
#[cfg(feature = "iface-kiss")]
pub use interface::kiss_iface::{KissFactory, KissIfaceConfig};
#[cfg(feature = "iface-local")]
pub use interface::local::{
    LocalClientConfig, LocalClientFactory, LocalServerConfig, LocalServerFactory,
};
#[cfg(feature = "iface-pipe")]
pub use interface::pipe::{PipeConfig, PipeFactory};
pub use interface::registry::InterfaceRegistry;
#[cfg(feature = "iface-rnode")]
pub use interface::rnode::{RNodeConfig, RNodeFactory, RNodeMultiFactory, RNodeSubConfig};
#[cfg(feature = "iface-serial")]
pub use interface::serial_iface::{SerialFactory, SerialIfaceConfig};
#[cfg(feature = "iface-tcp")]
pub use interface::tcp::{TcpClientConfig, TcpClientFactory};
#[cfg(feature = "iface-tcp")]
pub use interface::tcp_server::{TcpServerConfig, TcpServerFactory};
#[cfg(feature = "iface-udp")]
pub use interface::udp::{UdpConfig, UdpFactory};
#[cfg(all(feature = "iface-weave", target_os = "linux"))]
pub use interface::weave::{
    parse_device_frame as parse_weave_device_frame, WdclFrame, WeaveConfig, WeaveFactory,
    WeaveInput, WeaveLogFrame, WeavePeerState, WeaveState,
};
pub use interface::{install_socket_protector, SocketProtector, SocketProtectorGuard};
pub use interface::{
    InterfaceConfigData, InterfaceFactory, StartContext, StartResult, SubInterface,
};
pub use link_manager::{LinkManager, LinkManagerAction, RequestFailure, RequestResponse};
pub use link_send::{LinkSendError, LinkSendReceipt};
pub use link_send::{
    LinkSendError as TransmissionError, LinkSendReceipt as TransmissionReceipt, PacketSendReceipt,
};
pub use management::ManagementConfig;
pub use node::{ChannelSendError, IfacConfig, InterfaceConfig, NodeConfig, RnsNode, SendError};
#[cfg(feature = "hooks")]
pub use provider_bridge::{
    HookProviderEventEnvelope, OverflowPolicy, ProviderBridge, ProviderBridgeConfig,
    ProviderEnvelope, ProviderMessage,
};
pub use resource::{
    ReceivedResourceFile, ResourceReceiveMode, ResourceTransferError, ResourceTransferId,
};
pub use rpc::{RpcAddr, RpcClient, RpcServer};
pub use serial::Parity;
#[cfg(feature = "iface-local")]
pub use shared_client::SharedClientConfig;
pub use storage::{
    FsRatchetStore, KnownDestination, RatchetCleanupStats, RatchetEntry, RatchetStore, StoragePaths,
};

// Re-export commonly used types from rns-core
pub use rns_core::constants::{
    MODE_ACCESS_POINT, MODE_BOUNDARY, MODE_FULL, MODE_GATEWAY, MODE_INTERNAL, MODE_POINT_TO_POINT,
    MODE_ROAMING,
};
pub use rns_core::link::TeardownReason;
pub use rns_core::transport::types::InterfaceId;
pub use rns_core::types::{
    DestHash, DestinationType, Direction, IdentityHash, LinkId, PacketHash, ProofStrategy,
};

#[cfg(test)]
mod test_support;

#[cfg(test)]
mod module_initialization_tests {
    #[test]
    fn profiler_is_available_from_the_crate_root_without_late_imports() {
        let sample = crate::profiling::profile("entry117.crate-root");
        drop(sample);
        assert_eq!(
            crate::profiling::results()["entry117.crate-root"]
                .stats_all
                .count,
            1
        );
    }
}