update port-forward

1. fix multi remote port override.
2. add connection.rs port-forward failed to close
This commit is contained in:
csf
2022-08-29 19:45:06 +08:00
parent 37617fa888
commit fcc62febb1
4 changed files with 14 additions and 6 deletions

View File

@@ -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,10 +2429,13 @@ async fn start_one_port_forward(
receiver,
key,
token,
handler.lc.clone(),
remote_host,
remote_port,
)
.await
{
handler.on_error(&format!("Failed to listen on {}: {}", port, err));
}
log::info!("port forward (:{}) exit", port);
}
}