reshape swarm peers: domain-as-key, certFingerprint field

This commit is contained in:
damocles 2026-05-31 23:29:30 +02:00 committed by mara
commit 52cfc3ea1c
3 changed files with 45 additions and 66 deletions

View file

@ -267,19 +267,14 @@ struct StateSnapshot {
/// unset — chrome omits the swarm segment of the breadcrumb.
swarm_name: Option<String>,
/// Peer hives in the same swarm. Parsed from `HYPERHIVE_PEERS`
/// (JSON array of `{label,domain}` objects, emitted by the c0re
/// NixOS module from `services.hyperhive.peers`). Empty on
/// single-hive deploys. Feeds the P33RS dashboard tab. Each entry
/// exposes `name` (the operator-chosen label) and `url` (dashboard
/// link derived as `http://<domain>/`; HTTP-only until the gateway
/// has TLS and the scheme is threaded through).
/// (JSON array of `{domain,cert_fingerprint}` objects, emitted by
/// the c0re NixOS module from `services.hyperhive.swarm.peers`).
/// Empty on single-hive deploys. Feeds the P33RS dashboard tab.
peer_hives: Vec<PeerHiveView>,
}
/// One peer hive for the P33RS dashboard tab. Derived from
/// `HYPERHIVE_PEERS` env; `url` is the peer's dashboard root so the
/// tab can render a clickable card without knowing the remote port.
/// HTTP-only until per-peer TLS is wired through the gateway layer.
/// `HYPERHIVE_PEERS` env; `url` is the peer's HTTPS dashboard root.
#[derive(Serialize)]
struct PeerHiveView {
name: String,
@ -498,15 +493,16 @@ async fn api_state(headers: HeaderMap, State(state): State<AppState>) -> axum::J
}
/// Parse `HYPERHIVE_PEERS` env var into dashboard-ready `PeerHiveView`
/// entries. The env var is a JSON array of `{label, domain}` objects
/// emitted by the c0re NixOS module from `services.hyperhive.peers`.
/// Each entry becomes `{ name: label, url: "http://domain/" }` for the
/// P33RS tab. Returns empty vec when unset (single-hive deploy).
/// entries. The env var is a JSON array of `{domain, cert_fingerprint}`
/// objects emitted by the c0re NixOS module from
/// `services.hyperhive.swarm.peers`. Each entry becomes
/// `{ name: domain, url: "https://domain/" }` for the P33RS tab.
/// Returns empty vec when unset (single-hive deploy).
fn parse_peer_hives() -> Vec<PeerHiveView> {
#[derive(serde::Deserialize)]
struct Raw {
label: String,
domain: String,
cert_fingerprint: Option<String>,
}
let Ok(json) = std::env::var("HYPERHIVE_PEERS") else {
return Vec::new();
@ -517,8 +513,8 @@ fn parse_peer_hives() -> Vec<PeerHiveView> {
};
raw.into_iter()
.map(|r| PeerHiveView {
name: r.label,
url: format!("http://{}/", r.domain),
name: r.domain.clone(),
url: format!("https://{}/", r.domain),
})
.collect()
}