diff --git a/libs/hbb_common b/libs/hbb_common index 4d5b935..20bea85 160000 --- a/libs/hbb_common +++ b/libs/hbb_common @@ -1 +1 @@ -Subproject commit 4d5b935f16abe33e106b13f30877edb2960f53e9 +Subproject commit 20bea85903acbd701aed45d195e9206f2ea09edf diff --git a/src/main.rs b/src/main.rs index 96e0376..888fa11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,7 @@ fn main() -> ResultType<()> { -R, --rendezvous-servers=[HOSTS] 'Sets rendezvous servers, seperated by colon' -u, --software-url=[URL] 'Sets download url of RustDesk software of newest version' -r, --relay-servers=[HOST] 'Sets the default relay servers, seperated by colon' + -C, --change-id=[BOOL(default=Y)] 'Sets if support to change id' -k, --key=[KEY] 'Only allow the client with the same key'", DEFAULT_PORT, ); @@ -50,6 +51,7 @@ fn main() -> ResultType<()> { .map(|x| x.to_owned()) .collect(); let serial: i32 = get_arg("serial", "").parse().unwrap_or(0); + let id_change_support: bool = get_arg("change-id", "Y").to_uppercase() == "Y"; let rendezvous_servers: Vec = get_arg("rendezvous-servers", "") .split(",") .filter(|x| !x.is_empty() && test_if_valid_server(x, "rendezvous-server").is_ok()) @@ -69,6 +71,7 @@ fn main() -> ResultType<()> { get_arg("software-url", ""), &get_arg("key", ""), stop, + id_change_support, )?; Ok(()) } diff --git a/src/rendezvous_server.rs b/src/rendezvous_server.rs index 79ed121..2908475 100644 --- a/src/rendezvous_server.rs +++ b/src/rendezvous_server.rs @@ -164,6 +164,7 @@ impl RendezvousServer { software_url: String, key: &str, stop: Arc>, + id_change_support: bool, ) -> ResultType<()> { if !key.is_empty() { log::info!("Key: {}", key); @@ -171,6 +172,7 @@ impl RendezvousServer { log::info!("Listening on tcp/udp {}", addr); log::info!("Listening on tcp {}, extra port for NAT test", addr2); log::info!("relay-servers={:?}", relay_servers); + log::info!("change-id={:?}", id_change_support); let mut socket = FramedSocket::new(addr).await?; let (tx, mut rx) = mpsc::unbounded_channel::<(RendezvousMessage, SocketAddr)>(); let version = hbb_common::get_version_from_url(&software_url); @@ -202,6 +204,7 @@ impl RendezvousServer { &mut socket, key, stop.clone(), + id_change_support, ) .await; } @@ -215,6 +218,7 @@ impl RendezvousServer { socket: &mut FramedSocket, key: &str, stop: Arc>, + id_change_support: bool, ) { let mut timer = interval(Duration::from_millis(100)); loop { @@ -326,7 +330,9 @@ impl RendezvousServer { break; } let mut res = register_pk_response::Result::OK; - if let Some(peer) = rs.pm.get(&rk.id).await { + if !id_change_support { + res = register_pk_response::Result::NOT_SUPPORT; + } else if let Some(peer) = rs.pm.get(&rk.id).await { if peer.uuid != rk.uuid { res = register_pk_response::Result::ID_EXISTS; }