Files

12 KiB

Migrating to the 1.4 source API

The 1.4 line is published as v1.4.0 and is the source line Ratspeak builds from. These APIs and migration commands require a 1.4 build.

The 1.4 source line introduces explicit interface-capacity ownership and durable application admission. Existing published releases are unchanged. Migrate Reticulum dependents together to ~1.4.0; a source version alone is not publication.

Follow capacity, IFAC configuration, receipts and timing for the full API and configuration transition. In particular:

  • Replace InterfacePostInit::from_section with fallible try_from_section, and propagate semantic configuration errors before spawning interfaces.
  • LinkManager::set_link_packet_channel returns a result. The legacy tuple receiver cannot enable ProveApp; use the bounded typed packet channel and exact endpoint binding for application-controlled receipts.
  • Custom interface handles and entries must supply exact owner and typed packet capacity facts. Construct their bound sender before producer tasks start. Link endpoint bindings retain the interface owner captured from the admitted request/proof, rather than looking up whichever interface currently has an ID.
  • Request admission and proof validation are separate. Retain one attempt-owned result and deadline; cancelled/refused attempts cannot change a replacement.
  • rns_interface::rnode::RNodeStream is an opaque struct; its Serial and Tcp variants are no longer public. Open streams with open_serial or connect_tcp; try_clone, description, and the Read/Write implementations are unchanged.

Build InterfaceStatRpcEntry with ..Default::default() and InterfaceEntry with ..InterfaceEntry::new(...), so fields added on the 1.4 line stay source compatible.

rns_link::mtu_discovery::SignallingData remains a public re-export of the shared rns_wire::link_signalling::SignallingData; existing imports and checked handshake callers can continue using that alias. Cargo-public-api renders canonical type paths from rns-wire, so its twelve moved snapshot lines are explicitly recorded despite preserved source identity. new/pack/unpack remain low-level representation helpers; use checked signalling APIs for admission.

rpc::InterfaceStatEntry::ifac_size is now Option<usize>, None when the interface has no IFAC, and the entry gains ifac_signature and ifac_netname, as in Python's interface stats. Interface sections start only when interface_enabled or enabled is true; add enabled = yes to sections that relied on the old default. ConfigSection::interface_enabled, has_enable_key and invalid_enable_key expose that rule to embedders.

Strict persistence accepts every filesystem; DurabilityUnsupported no longer reports an unqualified filesystem. persistence::storage_risk classifies network or user-space (Remote) and RAM-backed (Volatile) storage so applications can warn their users.

I2PServerConfig gains b32, which receives the server's b32 address when SAM creates its session, and key_path, the file that keeps the server's private key, and so its address, across sessions; the runtime sets it to Python's key file under storage/i2p. i2p::destination_b32 derives the address from a SAM private key; build the config with new. discovery::announcer::Announcer::reconfigure replaces a registered interface's config but keeps its announce interval.

TunnelEntry::interface_id is now Option<InterfaceId>, None while the tunnel is unbound, instead of the id-0 sentinel. spawn_local_server and spawn_i2p_server take the listener's allocated InterfaceId, which their accepted clients report as parent_id. InterfaceEntry::parent_id carries it into transport; set it from InterfaceHandle::parent_id. Persisted tunnels now load unbound into the tunnel table, so TransportActor::pending_tunnel_entries is gone.

TransportActor::discovery_pr_tags is a HashSet<[u8; 32]> of destination hash plus tag, with no timestamps, and discovery_pr_tags_prev holds the previous generation; a tag in either is a duplicate. PacketHashlist::insert no longer rotates: the owner calls rotate_if_full from its periodic job. TransportMessage::RegisterAnnounceSubscription takes a paused flag, which AnnounceSubscription::pause and resume set.

TunnelSynthesisData::unpack accepts exactly 176 bytes, and is_signed is the check transport applies before admitting one. The TCP, Backbone and I2P client configs' python_name is the Python str() their syntheses hash. Announces join the tunnel named by their interface's latest synthesis, which handle_tunnel and TunnelTable::insert record and TunnelTable::void_interface clears; writing interface_id directly no longer rebinds an interface. handle_tunnel no longer takes a timeout: a tunnel expires TUNNEL_TIMEOUT after its synthesis, as in Python. TunnelTable::cull_expired and cull_expired_batch also drop tunnels set to expire more than twice TUNNEL_TIMEOUT ahead.

TcpClientConfig, BackboneClientConfig and I2PClientConfig gain tunnel_identity. With a TunnelIdentity set, the client opens every connection with a tunnel synthesis signed by it; the runtime sets it from ReticulumHandle::transport_identity. Build these configs with new so the field defaults to None. A KISS-framed TCP client never synthesizes. Every TCP, Backbone and I2P client, the shared-instance TCP client included, drops its queued traffic when a connection opens after an outage or a failed attempt, and the Unix shared-instance client drops it when it reconnects.

TcpClientConfig gains i2p_tunneled, which gives a TCP connection tunneled over I2P Python's longer I2P socket timeouts; the runtime reads it from the interface's i2p_tunneled key. Build the config with new so it defaults to false.

Interface stats carry Python 1.5's per-interface counters. IngressController counts announces and path requests received and sent; InterfaceEntry gains protocol_violations, ifac_violations, packet_filter_hits and tx_dropped_bytes; InterfaceStatRpcEntry reports all of them plus parent_id; rpc::InterfaceStatEntry carries them, the listener's name, and now implements Default. Build it with ..Default::default(). The control port and remote management answer with one Python-shaped stats dict, so remote_management_schema is removed: decode a /status answer as [stats, link_count?], and a /path answer with rpc::decode_response_for_request. Remote management answers on the transport identity, so rnstatus -R and rnpath -R take its hash. A node with enable_transport off and no static_transport_identity gets a new management destination each start, as in Python. The runtime no longer reads storage/remote_management_identity, and leaves the file in place for the operator to delete.

Interface discovery carries Python 1.5's implementation keys. DiscoveryInfo gains impl_name and impl_version; build it with ..Default::default(). discovery::autoconnect::qualifies applies Python's auto-connect rule, with ReticulumConfig::autoconnect_unverified_implementations as its opt-in. The receiver no longer stores types that are never listed, so discovery::Reason gains UnlistedType and becomes #[non_exhaustive], so a match needs a wildcard arm.

rns_link::clock::ContinuousInstant reads a monotonic clock that keeps counting while the system is suspended: CLOCK_BOOTTIME on Linux and Android, CLOCK_MONOTONIC_RAW on Apple platforms and the performance counter on Windows, with std::time::Instant as a best-effort fallback elsewhere. Use it for a deadline that must hold in real time across a sleep. Check that deadline on a regular tick and when the runtime resumes; do not assume an outstanding async timer enforces the same suspend-inclusive deadline on every platform. Readings are process-local and do not convert to or from std::time::Instant. rns-link gains the target dependencies libc (unix) and windows-sys (Windows), so dependents that build with --locked refresh their lock files.

hkdf::derive_key_64 returns Zeroizing<[u8; 64]> and hkdf::hkdf_sha256 returns Zeroizing<Vec<u8>>, so derived keys are wiped when they are dropped. Pass &key[..] where a slice is expected and compare &okm[..] with a plain Vec; the bytes are unchanged. Zeroizing<[u8; 64]> is not Copy, so code that copied the key borrows it instead. token::decrypt still returns Vec<u8> and wipes its buffer when decryption fails; wrap a secret plaintext in Zeroizing. Identity::from_file reads at most 1025 bytes and refuses a file larger than 1 KiB. InterfacePostInit::ifac_passphrase is Option<Zeroizing<String>>, so the passphrase is wiped when the options are dropped: read it with .as_deref().map(String::as_str) and wrap a new one in Zeroizing::new. RuntimeInterfaceIfacConfig prints <redacted> in place of its passphrase. InterfaceEntry::ifac_key is Option<rns_identity::ifac::IfacKey>, one allocation that clones share and that is wiped when the last one drops, so interface tables never copy the key. with_ifac still takes the key bytes; otherwise set Some(key.into()) or IfacKey::derive(network_name, passphrase), and read the bytes through &*key. rns-crypto re-exports zeroize for crates that hold its wiped types without depending on it, and rns_identity::persistence::read_secret_file reads a bounded secret file into one wiped buffer. An I2P interface refuses a key file larger than 16 KiB and a SAM reply line longer than 64 KiB, and I2PServerConfig prints <redacted> in place of a configured key. rns-crypto enables the zeroize features of aes and cbc, so AES key schedules and CBC state are wiped when dropped; dependents that build with --locked refresh their lock files.

The compatibility floor remains unchanged. Its cumulative exact-removal list also retains the already-reviewed 1.3 migration for discovery ownership and nullable coordinates; it is not reclassified as a new 1.4 change. Additive struct fields can require literal-construction updates even when no old public line disappears. No whole-crate waiver or baseline reset is used.

Disk-backed Destination handlers can use LinkManager::register_deferred_request_handler after installing an exact endpoint dispatch handle. Existing synchronous handlers remain supported. The new callback receives DestinationRequest and a one-shot DeferredRequestResponder; move both into the actual bounded worker and return promptly. Read response_byte_limit() before allocating or retiring stored items. Check is_cancelled() before work, and retain the responder until the worker has actually stopped. respond(RequestOutcome) returns a typed completion receiver: Sent means the packet was queued or the response Resource started, not that the remote application accepted it.

Admission reserves one of four process-wide slots and a conservative share of 256 MiB before invoking the callback. Charge is sixteen times request capacity, eight times the effective response capacity, plus 16 MiB of construction scratch. The token may report a smaller limit than registration requested. This accounts for the bounded handler's planning structures and current response/Resource construction; arbitrary application allocations are outside this contract. Response allocation capacity, including optional follow-up Resource metadata, must fit the token. Requests expire after 120 seconds. Refused admission never invokes the callback. Dropping a manager revokes response authority while a live worker retains its reservation; completed response Resources retain that same reservation until terminal cleanup.

Deferred handlers require exact endpoint ownership. Queued response packets and Resource advertisement, part, request, hash-map update and cancellation commands carry SendLinkEndpointExact authority. The actor rejects an old token even when a replacement uses the same Link ID, interface and role. Existing legacy send commands remain available; they do not acquire this generation-bound guarantee.