mod src; pub use src::*; use hbb_common::{allow_err, log}; use std::sync::{Arc, Mutex}; lazy_static::lazy_static! { static ref STOP: Arc> = Arc::new(Mutex::new(true)); } pub fn bootstrap(license: &str, host: &str) { let port = rendezvous_server::DEFAULT_PORT; let addr = format!("0.0.0.0:{}", port); let addr2 = format!("0.0.0.0:{}", port.parse::().unwrap_or(0) - 1); let relay_servers: Vec = vec![format!("{}:{}", host, relay_server::DEFAULT_PORT)]; let tmp_license = license.to_owned(); std::thread::spawn(move || { allow_err!(rendezvous_server::RendezvousServer::start( &addr, &addr2, relay_servers, 0, Default::default(), Default::default(), &tmp_license, STOP.clone(), )); }); let tmp_license = license.to_owned(); std::thread::spawn(move || { allow_err!(relay_server::start( relay_server::DEFAULT_PORT, &tmp_license, STOP.clone() )); }); } pub fn stop() { *STOP.lock().unwrap() = true; } pub fn start() { *STOP.lock().unwrap() = false; }