mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-15 00:41:01 +03:00
propagates the hash-handler continuation result through both connection loops, allowing incoming-only rejection to terminate the connection while preserving existing login flows.
This commit is contained in:
@@ -3548,7 +3548,7 @@ pub async fn handle_hash(
|
|||||||
hash: Hash,
|
hash: Hash,
|
||||||
interface: &impl Interface,
|
interface: &impl Interface,
|
||||||
peer: &mut Stream,
|
peer: &mut Stream,
|
||||||
) {
|
) -> bool {
|
||||||
lc.write().unwrap().hash = hash.clone();
|
lc.write().unwrap().hash = hash.clone();
|
||||||
// Take care of password application order
|
// Take care of password application order
|
||||||
|
|
||||||
@@ -3572,7 +3572,7 @@ pub async fn handle_hash(
|
|||||||
lc.write().unwrap().allow_switch_back_once();
|
lc.write().unwrap().allow_switch_back_once();
|
||||||
send_switch_login_request(lc.clone(), peer, uuid).await;
|
send_switch_login_request(lc.clone(), peer, uuid).await;
|
||||||
lc.write().unwrap().password_source = Default::default();
|
lc.write().unwrap().password_source = Default::default();
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3587,7 +3587,7 @@ pub async fn handle_hash(
|
|||||||
let mut msg = Message::new();
|
let mut msg = Message::new();
|
||||||
msg.set_misc(misc);
|
msg.set_misc(misc);
|
||||||
allow_err!(peer.send(&msg).await);
|
allow_err!(peer.send(&msg).await);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// last password
|
// last password
|
||||||
@@ -3651,7 +3651,7 @@ pub async fn handle_hash(
|
|||||||
interface.msgbox("terminal-admin-login", "", "", "");
|
interface.msgbox("terminal-admin-login", "", "", "");
|
||||||
}
|
}
|
||||||
lc.write().unwrap().hash = hash;
|
lc.write().unwrap().hash = hash;
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let password = if password.is_empty() {
|
let password = if password.is_empty() {
|
||||||
@@ -3677,6 +3677,7 @@ pub async fn handle_hash(
|
|||||||
|
|
||||||
send_login(lc.clone(), os_username, os_password, password, peer).await;
|
send_login(lc.clone(), os_username, os_password, password, peer).await;
|
||||||
lc.write().unwrap().hash = hash;
|
lc.write().unwrap().hash = hash;
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -3804,7 +3805,7 @@ pub trait Interface: Send + Clone + 'static + Sized {
|
|||||||
fn on_error(&self, err: &str) {
|
fn on_error(&self, err: &str) {
|
||||||
self.msgbox("error", "Error", err, "");
|
self.msgbox("error", "Error", err, "");
|
||||||
}
|
}
|
||||||
async fn handle_hash(&self, pass: &str, hash: Hash, peer: &mut Stream);
|
async fn handle_hash(&self, pass: &str, hash: Hash, peer: &mut Stream) -> bool;
|
||||||
async fn handle_login_from_ui(
|
async fn handle_login_from_ui(
|
||||||
&self,
|
&self,
|
||||||
os_username: String,
|
os_username: String,
|
||||||
|
|||||||
@@ -1353,9 +1353,13 @@ impl<T: InvokeUiSession> Remote<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(message::Union::Hash(hash)) => {
|
Some(message::Union::Hash(hash)) => {
|
||||||
self.handler
|
if !self
|
||||||
|
.handler
|
||||||
.handle_hash(&self.handler.password.clone(), hash, peer)
|
.handle_hash(&self.handler.password.clone(), hash, peer)
|
||||||
.await;
|
.await
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Some(message::Union::LoginResponse(lr)) => match lr.union {
|
Some(message::Union::LoginResponse(lr)) => match lr.union {
|
||||||
Some(login_response::Union::Error(err)) => {
|
Some(login_response::Union::Error(err)) => {
|
||||||
|
|||||||
@@ -150,7 +150,9 @@ async fn connect_and_login(
|
|||||||
let msg_in = Message::parse_from_bytes(&bytes)?;
|
let msg_in = Message::parse_from_bytes(&bytes)?;
|
||||||
match msg_in.union {
|
match msg_in.union {
|
||||||
Some(message::Union::Hash(hash)) => {
|
Some(message::Union::Hash(hash)) => {
|
||||||
interface.handle_hash(password, hash, &mut stream).await;
|
if !interface.handle_hash(password, hash, &mut stream).await {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Some(message::Union::LoginResponse(lr)) => match lr.union {
|
Some(message::Union::LoginResponse(lr)) => match lr.union {
|
||||||
Some(login_response::Union::Error(err)) => {
|
Some(login_response::Union::Error(err)) => {
|
||||||
|
|||||||
@@ -1878,8 +1878,8 @@ impl<T: InvokeUiSession> Interface for Session<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_hash(&self, pass: &str, hash: Hash, peer: &mut Stream) {
|
async fn handle_hash(&self, pass: &str, hash: Hash, peer: &mut Stream) -> bool {
|
||||||
handle_hash(self.lc.clone(), pass, hash, self, peer).await;
|
handle_hash(self.lc.clone(), pass, hash, self, peer).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_login_from_ui(
|
async fn handle_login_from_ui(
|
||||||
|
|||||||
Reference in New Issue
Block a user