Artifact 8e767e10b523a2fe64bf9483e78030154f37e9d363c2d1e89127cf4a281dbdf0:
- File
iroh-sidecar/src/endpoint.rs
— part of check-in
[eb4b6f52d0]
at
2026-08-12 20:35:17
on branch main
— chore(deps): update Go, Hugo, and cargo dependencies (#194)
* chore(deps): update Go, Hugo, and cargo dependencies
- nats.go 1.49→1.53.1, nats-server 2.12.6→2.14.5, otel 1.43→1.45, modernc sqlite 1.46→1.56, libfossil 0.6.2→0.6.3, hextra 0.12.2→0.12.3 - cargo update for iroh-sidecar; ed25519/pkcs8/signature pinned to the rc series required by iroh's ed25519-dalek 3.0.0-pre.1 - fix traceparent test: nats.go ≥1.50 preserves header case and Get is exact-match; assert via natshdr.Carrier - rustfmt pass on sidecar sources
* chore(deps): bump iroh 0.97→1.0.3, fixes hickory-proto security alerts
SecretKey::generate no longer takes an rng; drop now-unused rand dep. Verified with make test-iroh (peer sync + convergence e2e).
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> (user: [email protected], size: 1401) [annotate] [blame] [check-ins using]
use iroh::{endpoint::presets, Endpoint, SecretKey}; use std::path::Path; use tokio::fs; /// Load or generate an Ed25519 keypair, then bind an iroh Endpoint. pub async fn create_endpoint( key_path: &Path, alpns: &[Vec<u8>], ) -> anyhow::Result<(Endpoint, String)> { let secret_key = load_or_generate_key(key_path).await?; let endpoint_id = secret_key.public().to_string(); let endpoint = Endpoint::builder(presets::N0) .secret_key(secret_key) .alpns(alpns.to_vec()) .bind() .await?; tracing::info!(%endpoint_id, "iroh endpoint bound"); Ok((endpoint, endpoint_id)) } async fn load_or_generate_key(path: &Path) -> anyhow::Result<SecretKey> { if path.exists() { let bytes = fs::read(path).await?; // Expect exactly 32 raw bytes (Ed25519 secret scalar). let arr: [u8; 32] = bytes .try_into() .map_err(|_| anyhow::anyhow!("key file is not 32 bytes"))?; let key = SecretKey::from_bytes(&arr); tracing::info!("loaded existing keypair from {}", path.display()); Ok(key) } else { let key = SecretKey::generate(); if let Some(parent) = path.parent() { fs::create_dir_all(parent).await?; } fs::write(path, key.to_bytes()).await?; tracing::info!("generated new keypair at {}", path.display()); Ok(key) } }