2020-03-06 17:18:22 +08:00
|
|
|
|
// https://tools.ietf.org/rfc/rfc5128.txt
|
|
|
|
|
// https://blog.csdn.net/bytxl/article/details/44344855
|
|
|
|
|
|
2022-05-12 20:00:33 +08:00
|
|
|
|
use flexi_logger::*;
|
|
|
|
|
use hbb_common::{bail, config::RENDEZVOUS_PORT, ResultType};
|
|
|
|
|
use hbbs::{common::*, *};
|
|
|
|
|
|
|
|
|
|
const RMEM: usize = 0;
|
2020-03-06 17:18:22 +08:00
|
|
|
|
|
2021-03-19 16:38:10 +08:00
|
|
|
|
fn main() -> ResultType<()> {
|
2022-05-12 20:00:33 +08:00
|
|
|
|
let _logger = Logger::try_with_env_or_str("info")?
|
|
|
|
|
.log_to_stdout()
|
|
|
|
|
.format(opt_format)
|
|
|
|
|
.write_mode(WriteMode::Async)
|
|
|
|
|
.start()?;
|
2020-09-18 13:04:39 +08:00
|
|
|
|
let args = format!(
|
2020-09-18 17:07:17 +08:00
|
|
|
|
"-c --config=[FILE] +takes_value 'Sets a custom config file'
|
|
|
|
|
-p, --port=[NUMBER(default={})] 'Sets the listening port'
|
2020-09-24 17:26:58 +08:00
|
|
|
|
-s, --serial=[NUMBER(default=0)] 'Sets configure update serial number'
|
2020-09-18 17:07:17 +08:00
|
|
|
|
-R, --rendezvous-servers=[HOSTS] 'Sets rendezvous servers, seperated by colon'
|
2020-09-21 22:56:38 +08:00
|
|
|
|
-u, --software-url=[URL] 'Sets download url of RustDesk software of newest version'
|
2021-03-30 16:11:56 +08:00
|
|
|
|
-r, --relay-servers=[HOST] 'Sets the default relay servers, seperated by colon'
|
2022-05-12 20:00:33 +08:00
|
|
|
|
-M, --rmem=[NUMBER(default={})] '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'
|
2022-07-13 00:22:45 +08:00
|
|
|
|
, --mask=[MASK] 'Determine if the connection comes from LAN, e.g. 192.168.0.0/16'
|
2021-03-30 16:01:22 +08:00
|
|
|
|
-k, --key=[KEY] 'Only allow the client with the same key'",
|
2022-05-12 20:00:33 +08:00
|
|
|
|
RENDEZVOUS_PORT,
|
|
|
|
|
RMEM,
|
2020-09-18 13:04:39 +08:00
|
|
|
|
);
|
2022-05-12 20:00:33 +08:00
|
|
|
|
init_args(&args, "hbbs", "RustDesk ID/Rendezvous Server");
|
|
|
|
|
let port = get_arg_or("port", RENDEZVOUS_PORT.to_string()).parse::<i32>()?;
|
|
|
|
|
if port < 3 {
|
|
|
|
|
bail!("Invalid port");
|
2021-04-10 01:16:02 +08:00
|
|
|
|
}
|
2022-05-12 20:00:33 +08:00
|
|
|
|
let rmem = get_arg("rmem").parse::<usize>().unwrap_or(RMEM);
|
|
|
|
|
let serial: i32 = get_arg("serial").parse().unwrap_or(0);
|
2022-05-13 09:56:44 +08:00
|
|
|
|
RendezvousServer::start(port, serial, &get_arg("key"), rmem)?;
|
2020-03-06 17:18:22 +08:00
|
|
|
|
Ok(())
|
2020-03-09 19:35:57 +08:00
|
|
|
|
}
|