mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
refactoring conn audit, add session_id (both session_id and conn_id on
sever side), use session_id instead of conn_id for client id, and remove conn_id in protobuf
This commit is contained in:
@@ -192,6 +192,7 @@ pub struct Connection {
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
tx_desktop_ready: mpsc::Sender<()>,
|
||||
closed: bool,
|
||||
}
|
||||
|
||||
impl ConnInner {
|
||||
@@ -320,8 +321,10 @@ impl Connection {
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
tx_desktop_ready: _tx_desktop_ready,
|
||||
closed: false,
|
||||
};
|
||||
if !conn.on_open(addr).await {
|
||||
conn.closed = true;
|
||||
// sleep to ensure msg got received.
|
||||
sleep(1.).await;
|
||||
return;
|
||||
@@ -563,7 +566,7 @@ impl Connection {
|
||||
match &m.union {
|
||||
Some(misc::Union::StopService(_)) => {
|
||||
conn.send_close_reason_no_retry("").await;
|
||||
conn.on_close("stop service", true).await;
|
||||
conn.on_close("stop service", false).await;
|
||||
break;
|
||||
}
|
||||
_ => {},
|
||||
@@ -634,6 +637,7 @@ impl Connection {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
try_stop_record_cursor_pos();
|
||||
}
|
||||
conn.on_close("End", true).await;
|
||||
log::info!("#{} connection loop exited", id);
|
||||
}
|
||||
|
||||
@@ -867,6 +871,7 @@ impl Connection {
|
||||
v["id"] = json!(Config::get_id());
|
||||
v["uuid"] = json!(crate::encode64(hbb_common::get_uuid()));
|
||||
v["conn_id"] = json!(self.inner.id);
|
||||
v["session_id"] = json!(self.lr.session_id);
|
||||
tokio::spawn(async move {
|
||||
allow_err!(Self::post_audit_async(url, v).await);
|
||||
});
|
||||
@@ -948,7 +953,6 @@ impl Connection {
|
||||
let mut res = LoginResponse::new();
|
||||
let mut pi = PeerInfo {
|
||||
username: username.clone(),
|
||||
conn_id: self.inner.id,
|
||||
version: VERSION.to_owned(),
|
||||
..Default::default()
|
||||
};
|
||||
@@ -1228,6 +1232,7 @@ impl Connection {
|
||||
.lock()
|
||||
.unwrap()
|
||||
.retain(|_, s| s.last_recv_time.lock().unwrap().elapsed() < SESSION_TIMEOUT);
|
||||
// last_recv_time is a mutex variable shared with connection, can be updated lively.
|
||||
if let Some(session) = session {
|
||||
if session.name == self.lr.my_name
|
||||
&& session.session_id == self.lr.session_id
|
||||
@@ -2179,6 +2184,10 @@ impl Connection {
|
||||
}
|
||||
|
||||
async fn on_close(&mut self, reason: &str, lock: bool) {
|
||||
if self.closed {
|
||||
return;
|
||||
}
|
||||
self.closed = true;
|
||||
log::info!("#{} Connection closed: {}", self.inner.id(), reason);
|
||||
if lock && self.lock_after_session_end && self.keyboard {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
|
||||
@@ -484,7 +484,6 @@ fn check_get_displays_changed_msg() -> Option<Message> {
|
||||
let displays = check_displays_new()?;
|
||||
let (current, displays) = get_displays_2(&displays);
|
||||
let mut pi = PeerInfo {
|
||||
conn_id: crate::SYNC_PEER_INFO_DISPLAYS,
|
||||
..Default::default()
|
||||
};
|
||||
pi.displays = displays.clone();
|
||||
|
||||
Reference in New Issue
Block a user