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:
- Extraction: Parses the
Hostheader to determine the target domain (e.g.,saif.alt). - TLD Lookup: Extracts the TLD (
.alt) and asks theTldRegistryif it’s supported. If not, returns 403. - Swarm Retrieval: Asks
SwarmManagertoget_or_spawn_swarm(".alt"). This guarantees a live libp2p node for the specific network fork. - DHT Resolution: Sends a
NetworkCommand::GetRecordto the swarm to look upsaif.alton the DHT.
Important
5. Signature Verification: Crucially, it validates the DHT record’s cryptographic signature using the specific
network_idconfigured for.altin the registry. A record signed with the default.kinnetwork ID is rejected.
- Proxying / IPFS Routing: If the record contains a P2P peer address, it sends a
NetworkCommand::SendProxyRequest. If the record is aDnsRecord::IPFS(cid), it automatically routes the request to an IPFS HTTP gateway. - 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.
start_auto_updater()spawns a background loop running every 24 hours (with a 1-hour exponential backoff interval during failures). It silently disables itself ifregistry_urlorupdater_public_keyare missing from the configuration.- It hits the GitHub API (configured via
registry_urlinatlas.json) to list all.jsonfiles in the central repository. - It downloads any new or updated configuration files, as well as their corresponding
.sigfiles.
Important
4. It cryptographically verifies the Ed25519 signature of each configuration file against the
updater_public_key. Unsigned or invalid files are rejected.
- Valid files are written to the local
networks/folder, andregistry.load_from_dir()is called to refresh the internal map. - 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.