Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/open-humanity/blob/main/crates/beacon/src/main.rs # open-humanity Privacy-first peer assistance network for sovereign autonomous agents Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `open-humanity / crates / beacon / src / main.rs` 41 lines ยท 1364 bytes Raw Blame History 1 //! Open Humanity relay daemon. 2 //! 3 //! `BEACON_PORT` sets the UDP port (default 18098) and `BEACON_BIND` the address 4 //! (default 0.0.0.0). A value that is set but empty or not valid stops the relay: 5 //! it never falls back to all interfaces. `BEACON_LINKS` names relays to link with 6 //! (`address:port`, separated by commas). 7 8 use beacon::{listen_addr, parse_links, RelayConfig, RelayServer}; 9 use tracing::info; 10 11 #[tokio::main] 12 async fn main() -> Result<(), Box> { 13 tracing_subscriber::fmt::init(); 14 info!("Starting Open Humanity relay"); 15 16 let bind = std::env::var("BEACON_BIND").ok(); 17 let port = std::env::var("BEACON_PORT").ok(); 18 let addr = match listen_addr(bind.as_deref(), port.as_deref()) { 19 Ok(addr) => addr, 20 Err(reason) => { 21 eprintln!("Error: {reason}"); 22 std::process::exit(2); 23 } 24 }; 25 26 let links = match parse_links(std::env::var("BEACON_LINKS").ok().as_deref()) { 27 Ok(links) => links, 28 Err(reason) => { 29 eprintln!("Error: {reason}"); 30 std::process::exit(2); 31 } 32 }; 33 34 let relay = RelayServer::bind_addr(addr, RelayConfig::default()).await?; 35 if !links.is_empty() { 36 info!("Linking with {} relay(s)", links.len()); 37 relay.set_links(&links).await; 38 } 39 relay.run_loop().await?; 40 Ok(()) 41 }