mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-06 16:31:27 +03:00
31
src/ipc.rs
31
src/ipc.rs
@@ -280,6 +280,8 @@ pub enum Data {
|
||||
not(any(target_os = "android", target_os = "ios"))
|
||||
))]
|
||||
ControllingSessionCount(usize),
|
||||
#[cfg(target_os = "windows")]
|
||||
PortForwardSessionCount(Option<usize>),
|
||||
}
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
@@ -692,6 +694,25 @@ async fn handle(data: Data, stream: &mut Connection) {
|
||||
// This branch is left blank for unification and further use.
|
||||
}
|
||||
},
|
||||
#[cfg(target_os = "windows")]
|
||||
Data::PortForwardSessionCount(c) => match c {
|
||||
None => {
|
||||
let count = crate::server::AUTHED_CONNS
|
||||
.lock()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|c| c.conn_type == crate::server::AuthConnType::PortForward)
|
||||
.count();
|
||||
allow_err!(
|
||||
stream
|
||||
.send(&Data::PortForwardSessionCount(Some(count)))
|
||||
.await
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
// Port forward session count is only a get value.
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -1201,6 +1222,16 @@ pub async fn notify_server_to_check_hwcodec() -> ResultType<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub async fn get_port_forward_session_count(ms_timeout: u64) -> ResultType<usize> {
|
||||
let mut c = connect(ms_timeout, "").await?;
|
||||
c.send(&Data::PortForwardSessionCount(None)).await?;
|
||||
if let Some(Data::PortForwardSessionCount(Some(count))) = c.next_timeout(ms_timeout).await? {
|
||||
return Ok(count);
|
||||
}
|
||||
bail!("Failed to get port forward session count");
|
||||
}
|
||||
|
||||
#[cfg(feature = "hwcodec")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
|
||||
Reference in New Issue
Block a user