Expand description
LAN peering: direct device-to-device sync within a single user’s own devices (SSoT: Peering).
Peering is an accelerator, never a replacement for server sync: two of a user’s devices on the same network move a freshly-imported asset directly instead of round-tripping every byte through the server. If no peer answers, discovery fails silently and the device falls back to ordinary sync — nothing depends on it succeeding.
This module owns only the two things peering introduces of its own — a LAN discovery mechanism and a transport — and borrows everything else:
discovery— the opaque, rotating mDNS advertisement (it must leak neither a user handle nor a device name) and theDiscoveryseam. The mDNS responder is mocked in tests and is where a real pure-Rust responder (mdns-sd) plugs in; discovery stays deterministic so every rule is a unit test.channel— a mutually-authenticated TLS 1.3 channel with no CA. The TLS layer proves only classical possession; the hybrid identity check (that the peer chains to the shared User IK exactly as published in the device directory) rides above the channel, before any payload byte, bound to the session via the RFC 5705 TLS exporter.session— the directory anti-rollback floor, the per-source handshake rate limit, and the per-request revocation check that quarantines deliveries made after a revocation.delta— “what’s missing” is the complement of two content-address sets, reusing the sync-cursor model rather than inventing a diff.transfer— the payload is a delta-scoped backup artifact, fetched with rangedGET(resumable, idempotent) and ingested through the same backup restore path (capsule-core::backup), with chain-aware forward-vs-stale reconciliation so a peer can never resurrect a locally-superseded asset.delegation— upload delegation: a device hands sealed, signed upload bundles to another device of the account, which uploads them as an opaque courier; the origin releases its original only on custody it checked itself.
Trust is identity, never content: the channel authenticates who you talk to; every
received asset is still re-verified by restore (ciphertext hash, STREAM tags, verify_asset).
Re-exports§
pub use channel::ArtifactSecret;pub use channel::HandshakeRole;pub use channel::LocalPeer;pub use channel::Message;pub use channel::Offered;pub use channel::Offering;pub use channel::PEERING_PROTOCOL;pub use channel::PEERING_PROTOCOL_MIN;pub use channel::PeerChannel;pub use channel::PeerClient;pub use channel::PeerHello;pub use channel::PinnedTrust;pub use channel::RangeFailure;pub use channel::ServeReport;pub use channel::ServedRange;pub use channel::UpdateDevice;pub use channel::VerifiedPeer;pub use channel::VersionWindow;pub use channel::accept;pub use channel::connect;pub use channel::serve;pub use delegation::DelegateInbox;pub use delegation::DelegatedUpload;pub use delegation::Delegation;pub use delegation::DelegationError;pub use delegation::DelegationState;pub use delegation::DeleteDisposition;pub use delegation::HandOff;pub use delegation::HandOffAck;pub use delegation::HeldFailure;pub use delegation::MemoryInbox;pub use delegation::OriginLedger;pub use delegation::PERMANENT_UPLOAD_REFUSALS;pub use delegation::Quarantine;pub use delegation::ReleaseOutcome;pub use delegation::RequeueReason;pub use delegation::SealedHandOff;pub use delegation::Settled;pub use delegation::TakenHandOff;pub use delegation::TakenHandOffs;pub use delegation::VerifiedHandOff;pub use delegation::accept_hand_off;pub use delegation::accept_hand_off_from;pub use delegation::dispose_failure;pub use delegation::offer_hand_offs;pub use delegation::seal;pub use delegation::settle;pub use delegation::take_hand_offs;pub use delegation::upload_hand_off;pub use delegation::verify_hand_off;pub use delta::OFFER_PAGE_CAP;pub use delta::Offer;pub use delta::OfferPage;pub use delta::decode_offer_page;pub use delta::missing_from;pub use delta::offer_bucket;pub use delta::symmetric_difference;pub use discovery::DiscoveredPeer;pub use discovery::Discovery;pub use discovery::MockDiscovery;pub use discovery::OpaqueAdvertisement;pub use discovery::RotationEpoch;pub use discovery::SERVICE_TYPE;pub use discovery::new_boot_id;pub use discovery::rotation_epoch;pub use session::DirectoryVersions;pub use session::HandshakeLimiter;pub use session::MemoryDirectoryVersions;pub use session::PeerSession;pub use session::TrustSource;pub use transfer::ArtifactBlobSource;pub use transfer::ChannelBlobSource;pub use transfer::DeltaExport;pub use transfer::LocalLibrary;pub use transfer::PeerRestore;pub use transfer::artifact_address;pub use transfer::build_delta_artifact;pub use transfer::ingest;pub use transfer::pull_artifact;pub use transfer::pull_over_channel;
Modules§
- channel
- Establishing the channel: mutually-authenticated TLS 1.3 with an application-layer hybrid identity check.
- delegation
- Upload delegation: a device hands sealed, signed upload bundles to another device of the same account, which uploads them later as an opaque courier (SSoT: Peering § Delegation).
- delta
- Determining the delta: what each side is missing.
- discovery
- LAN discovery: the opaque, rotating advertisement and the
Discoveryseam. - session
- What a peering session enforces after the handshake, and what guards the handshake itself.
- transfer
- What moves over the wire, and how it is applied.
Enums§
- Peering
Error - Everything peering can fail with. Peering is best-effort — a caller treats most of these as “no peer / fall back to server sync” — but the identity-check variants are load-bearing security rejections that must never be silently downgraded.
Functions§
- is_lan
- Whether
ipis on the local network: loopback, an RFC 1918 private or link-local IPv4 address, or an IPv6 unique-local (fc00::/7) or link-local (fe80::/10) address, including an IPv4-mapped one of those. Peering dials and admits only these, so a peering channel never leaves the LAN.