mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-28 23:59:05 +08:00
update port-forward
1. fix multi remote port override. 2. add connection.rs port-forward failed to close
This commit is contained in:
parent
37617fa888
commit
fcc62febb1
@ -568,7 +568,6 @@ impl Session {
|
||||
self.send(Data::AddPortForward(pf));
|
||||
}
|
||||
|
||||
|
||||
fn on_error(&self, err: &str) {
|
||||
self.msgbox("error", "Error", err);
|
||||
}
|
||||
@ -886,7 +885,6 @@ impl Connection {
|
||||
video_format: CodecFormat::Unknown,
|
||||
};
|
||||
|
||||
|
||||
match Client::start(&session.id, &key, &token, conn_type, session.clone()).await {
|
||||
Ok((mut peer, direct)) => {
|
||||
SERVER_KEYBOARD_ENABLED.store(true, Ordering::SeqCst);
|
||||
@ -2414,7 +2412,6 @@ pub fn get_session_id(id: String) -> String {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
async fn start_one_port_forward(
|
||||
handler: Session,
|
||||
port: i32,
|
||||
@ -2424,7 +2421,6 @@ async fn start_one_port_forward(
|
||||
key: &str,
|
||||
token: &str,
|
||||
) {
|
||||
handler.lc.write().unwrap().port_forward = (remote_host, remote_port);
|
||||
if let Err(err) = crate::port_forward::listen(
|
||||
handler.id.clone(),
|
||||
String::new(), // TODO
|
||||
@ -2433,6 +2429,9 @@ async fn start_one_port_forward(
|
||||
receiver,
|
||||
key,
|
||||
token,
|
||||
handler.lc.clone(),
|
||||
remote_host,
|
||||
remote_port,
|
||||
)
|
||||
.await
|
||||
{
|
||||
|
@ -1,3 +1,5 @@
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use crate::client::*;
|
||||
use hbb_common::{
|
||||
allow_err, bail,
|
||||
@ -48,6 +50,9 @@ pub async fn listen(
|
||||
ui_receiver: mpsc::UnboundedReceiver<Data>,
|
||||
key: &str,
|
||||
token: &str,
|
||||
lc: Arc<RwLock<LoginConfigHandler>>,
|
||||
remote_host: String,
|
||||
remote_port: i32,
|
||||
) -> ResultType<()> {
|
||||
let listener = tcp::new_listener(format!("0.0.0.0:{}", port), true).await?;
|
||||
let addr = listener.local_addr()?;
|
||||
@ -61,6 +66,7 @@ pub async fn listen(
|
||||
tokio::select! {
|
||||
Ok((forward, addr)) = listener.accept() => {
|
||||
log::info!("new connection from {:?}", addr);
|
||||
lc.write().unwrap().port_forward = (remote_host.clone(), remote_port);
|
||||
let id = id.clone();
|
||||
let password = password.clone();
|
||||
let mut forward = Framed::new(forward, BytesCodec::new());
|
||||
|
@ -949,6 +949,7 @@ impl Connection {
|
||||
addr
|
||||
))
|
||||
.await;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1253,7 +1253,6 @@ async fn start_one_port_forward(
|
||||
key: &str,
|
||||
token: &str,
|
||||
) {
|
||||
handler.lc.write().unwrap().port_forward = (remote_host, remote_port);
|
||||
if let Err(err) = crate::port_forward::listen(
|
||||
handler.id.clone(),
|
||||
handler.password.clone(),
|
||||
@ -1262,6 +1261,9 @@ async fn start_one_port_forward(
|
||||
receiver,
|
||||
key,
|
||||
token,
|
||||
handler.lc.clone(),
|
||||
remote_host,
|
||||
remote_port,
|
||||
)
|
||||
.await
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user