pub mod activity; pub mod blob; pub mod connection; pub mod content; pub mod control; pub mod crypto; pub mod group_key_distribution; pub mod http; pub mod export; pub mod identity; pub mod import; pub mod announcement; pub mod network; pub mod node; pub mod profile; pub mod protocol; pub mod storage; pub mod stun; pub mod types; pub mod upnp; pub mod web; // Re-export iroh types needed by consumers pub use iroh::{EndpointAddr, EndpointId}; use types::NodeId; /// Posting-identity public key of the bootstrap anchor. Only announcements /// authored by this key are accepted by `control::receive_post` for the /// `VisibilityIntent::Announcement` intent. Hardcoded so clients cannot be /// tricked into accepting a forged network-wide announcement. pub const DEFAULT_ANCHOR_POSTING_ID: NodeId = [ 0x17, 0xaf, 0x14, 0x19, 0x56, 0xae, 0x0b, 0x50, 0xdc, 0x1c, 0xb9, 0x24, 0x8c, 0xad, 0xf5, 0xfc, 0xa3, 0x71, 0xea, 0x2d, 0x85, 0x31, 0xac, 0x9a, 0xdd, 0x3c, 0x03, 0xca, 0xff, 0xc6, 0x14, 0x41, ]; /// Parse a connect string "nodeid_hex@ip:port" or "nodeid_hex@host:port" or bare "nodeid_hex" /// into (NodeId, EndpointAddr). Supports DNS hostnames via `ToSocketAddrs`. /// Shared utility used by CLI, Tauri, and bootstrap. pub fn parse_connect_string(s: &str) -> anyhow::Result<(NodeId, EndpointAddr)> { use std::net::ToSocketAddrs; if let Some((id_hex, addr_str)) = s.split_once('@') { let nid = parse_node_id_hex(id_hex)?; let endpoint_id = EndpointId::from_bytes(&nid)?; let all_addrs: Vec = addr_str .to_socket_addrs()? .collect(); if all_addrs.is_empty() { anyhow::bail!("could not resolve address: {}", addr_str); } let mut addr = EndpointAddr::from(endpoint_id); for sock_addr in all_addrs { addr = addr.with_ip_addr(sock_addr); } Ok((nid, addr)) } else { let nid = parse_node_id_hex(s)?; let endpoint_id = EndpointId::from_bytes(&nid)?; Ok((nid, EndpointAddr::from(endpoint_id))) } } /// Parse a hex-encoded node ID string into NodeId bytes. pub fn parse_node_id_hex(hex_str: &str) -> anyhow::Result { let bytes = hex::decode(hex_str)?; let id: NodeId = bytes .try_into() .map_err(|v: Vec| anyhow::anyhow!("expected 32 bytes, got {}", v.len()))?; Ok(id) }