Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Proxy Server and Auto-Updater

#![allow(unused)]
fn main() {
**Files:** `proxy.rs`, `updater.rs`
**Crate:** kinetic-atlas | **Stage:** 16
}

proxy.rs — The Universal Bridge

Runs an Axum HTTP server that intercepts traffic sent by the OS (configured via PAC or manual proxy settings).

Request Flow:

  1. Extraction: Parses the Host header to determine the target domain (e.g., saif.alt).
  2. TLD Lookup: Extracts the TLD (.alt) and asks the TldRegistry if it’s supported. If not, returns 403.
  3. Swarm Retrieval: Asks SwarmManager to get_or_spawn_swarm(".alt"). This guarantees a live libp2p node for the specific network fork.
  4. DHT Resolution: Sends a NetworkCommand::GetRecord to the swarm to look up saif.alt on the DHT.

Important

5. Signature Verification: Crucially, it validates the DHT record’s cryptographic signature using the specific network_id configured for .alt in the registry. A record signed with the default .kin network ID is rejected.

  1. Proxying / IPFS Routing: If the record contains a P2P peer address, it sends a NetworkCommand::SendProxyRequest. If the record is a DnsRecord::IPFS(cid), it automatically routes the request to an IPFS HTTP gateway.
  2. Response Streaming: Receives the remote peer or IPFS gateway’s response and streams it back to the local browser via standard HTTP.

updater.rs — Zero-Downtime Sync

Kinetic forks are created by the community. To ensure users can access new forks immediately, Atlas implements an auto-updater.

  1. start_auto_updater() spawns a background loop running every 24 hours (with a 1-hour exponential backoff interval during failures). It silently disables itself if registry_url or updater_public_key are missing from the configuration.
  2. It hits the GitHub API (configured via registry_url in atlas.json) to list all .json files in the central repository.
  3. It downloads any new or updated configuration files, as well as their corresponding .sig files.

Important

4. It cryptographically verifies the Ed25519 signature of each configuration file against the updater_public_key. Unsigned or invalid files are rejected.

  1. Valid files are written to the local networks/ folder, and registry.load_from_dir() is called to refresh the internal map.
  2. Because swarms are spawned dynamically on-demand by the SwarmManager, the daemon never needs to restart to support a new TLD. As soon as the updater writes the JSON, the TLD is immediately resolvable.