hbbr.rs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. use clap::App;
  2. mod common;
  3. mod relay_server;
  4. use flexi_logger::*;
  5. use hbb_common::{config::RELAY_PORT, ResultType};
  6. use relay_server::*;
  7. mod version;
  8. fn main() -> ResultType<()> {
  9. let _logger = Logger::try_with_env_or_str("info")?
  10. .log_to_stdout()
  11. .format(opt_format)
  12. .write_mode(WriteMode::Async)
  13. .start()?;
  14. let args = format!(
  15. "-p, --port=[NUMBER(default={})] 'Sets the listening port'
  16. -k, --key=[KEY] 'Only allow the client with the same key'
  17. ",
  18. RELAY_PORT,
  19. );
  20. let matches = App::new("hbbr")
  21. .version(version::VERSION)
  22. .author("Purslane Ltd. <info@rustdesk.com>")
  23. .about("RustDesk Relay Server")
  24. .args_from_usage(&args)
  25. .get_matches();
  26. if let Ok(v) = ini::Ini::load_from_file(".env") {
  27. if let Some(section) = v.section(None::<String>) {
  28. section.iter().for_each(|(k, v)| std::env::set_var(k, v));
  29. }
  30. }
  31. start(
  32. matches.value_of("port").unwrap_or(&RELAY_PORT.to_string()),
  33. matches.value_of("key").unwrap_or(""),
  34. )?;
  35. Ok(())
  36. }