main.rs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // https://tools.ietf.org/rfc/rfc5128.txt
  2. // https://blog.csdn.net/bytxl/article/details/44344855
  3. use flexi_logger::*;
  4. use hbb_common::{bail, config::RENDEZVOUS_PORT, ResultType};
  5. use hbbs::{common::*, *};
  6. const RMEM: usize = 0;
  7. fn main() -> ResultType<()> {
  8. let _logger = Logger::try_with_env_or_str("info")?
  9. .log_to_stdout()
  10. .format(opt_format)
  11. .write_mode(WriteMode::Async)
  12. .start()?;
  13. let args = format!(
  14. "-c --config=[FILE] +takes_value 'Sets a custom config file'
  15. -p, --port=[NUMBER(default={RENDEZVOUS_PORT})] 'Sets the listening port'
  16. -s, --serial=[NUMBER(default=0)] 'Sets configure update serial number'
  17. -R, --rendezvous-servers=[HOSTS] 'Sets rendezvous servers, separated by colon'
  18. -u, --software-url=[URL] 'Sets download url of RustDesk software of newest version'
  19. -r, --relay-servers=[HOST] 'Sets the default relay servers, separated by colon'
  20. -M, --rmem=[NUMBER(default={RMEM})] 'Sets UDP recv buffer size, set system rmem_max first, e.g., sudo sysctl -w net.core.rmem_max=52428800. vi /etc/sysctl.conf, net.core.rmem_max=52428800, sudo sysctl –p'
  21. , --mask=[MASK] 'Determine if the connection comes from LAN, e.g. 192.168.0.0/16'
  22. -k, --key=[KEY] 'Only allow the client with the same key'",
  23. );
  24. init_args(&args, "hbbs", "RustDesk ID/Rendezvous Server");
  25. let port = get_arg_or("port", RENDEZVOUS_PORT.to_string()).parse::<i32>()?;
  26. if port < 3 {
  27. bail!("Invalid port");
  28. }
  29. let rmem = get_arg("rmem").parse::<usize>().unwrap_or(RMEM);
  30. let serial: i32 = get_arg("serial").parse().unwrap_or(0);
  31. RendezvousServer::start(port, serial, &get_arg("key"), rmem)?;
  32. Ok(())
  33. }