mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-11 23:11:01 +03:00
cm: update a port-forward row's targets as tunnel channels come and go
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab
This commit is contained in:
@@ -436,6 +436,8 @@ class FfiModel with ChangeNotifier {
|
|||||||
parent.target?.chatModel.onVoiceCallIncoming();
|
parent.target?.chatModel.onVoiceCallIncoming();
|
||||||
} else if (name == 'update_voice_call_state') {
|
} else if (name == 'update_voice_call_state') {
|
||||||
parent.target?.serverModel.updateVoiceCallState(evt);
|
parent.target?.serverModel.updateVoiceCallState(evt);
|
||||||
|
} else if (name == 'update_port_forward') {
|
||||||
|
parent.target?.serverModel.updatePortForward(evt);
|
||||||
} else if (name == 'fingerprint') {
|
} else if (name == 'fingerprint') {
|
||||||
FingerprintState.find(peerId).value = evt['fingerprint'] ?? '';
|
FingerprintState.find(peerId).value = evt['fingerprint'] ?? '';
|
||||||
} else if (name == "sync_peer_hash_password_to_personal_ab") {
|
} else if (name == "sync_peer_hash_password_to_personal_ab") {
|
||||||
|
|||||||
@@ -768,6 +768,16 @@ class ServerModel with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updatePortForward(Map<String, dynamic> evt) {
|
||||||
|
final id = int.tryParse(evt['id']?.toString() ?? '');
|
||||||
|
final portForward = evt['port_forward']?.toString() ?? '';
|
||||||
|
if (id == null || portForward.isEmpty) return;
|
||||||
|
final index = _clients.indexWhere((c) => c.id == id);
|
||||||
|
if (index < 0) return;
|
||||||
|
_clients[index].portForward = portForward;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
void androidUpdatekeepScreenOn() async {
|
void androidUpdatekeepScreenOn() async {
|
||||||
if (!isAndroid) return;
|
if (!isAndroid) return;
|
||||||
var floatingWindowDisabled =
|
var floatingWindowDisabled =
|
||||||
|
|||||||
@@ -1517,6 +1517,13 @@ pub mod connection_manager {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_port_forward(&self, id: i32, port_forward: String) {
|
||||||
|
self.push_event(
|
||||||
|
"update_port_forward",
|
||||||
|
&[("id", &id.to_string()), ("port_forward", &port_forward)],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
fn change_theme(&self, dark: String) {
|
fn change_theme(&self, dark: String) {
|
||||||
self.push_event("theme", &[("dark", &dark)]);
|
self.push_event("theme", &[("dark", &dark)]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -348,6 +348,7 @@ pub enum Data {
|
|||||||
name: String,
|
name: String,
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
},
|
},
|
||||||
|
UpdatePortForward(String),
|
||||||
SystemInfo(Option<String>),
|
SystemInfo(Option<String>),
|
||||||
ClickTime(i64),
|
ClickTime(i64),
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
|||||||
@@ -2241,7 +2241,8 @@ impl Connection {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
self.port_forward_address = label.clone();
|
self.port_forward_address = label.clone();
|
||||||
log::debug!("port forward targets now {}", label);
|
log::info!("port forward targets now {}", label);
|
||||||
|
self.send_to_cm(ipc::Data::UpdatePortForward(label));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
@@ -72,6 +72,10 @@ impl InvokeUiCM for SciterHandler {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_port_forward(&self, id: i32, port_forward: String) {
|
||||||
|
self.call("updatePortForward", &make_args!(id, port_forward));
|
||||||
|
}
|
||||||
|
|
||||||
fn file_transfer_log(&self, _action: &str, _log: &str) {}
|
fn file_transfer_log(&self, _action: &str, _log: &str) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -434,6 +434,13 @@ handler.addConnection = function(id, is_file_transfer, is_view_camera, is_termin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handler.updatePortForward = function(id, port_forward) {
|
||||||
|
connections.map(function(c) {
|
||||||
|
if (c.id == id) c.port_forward = port_forward;
|
||||||
|
});
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
handler.removeConnection = function(id, close) {
|
handler.removeConnection = function(id, close) {
|
||||||
var i = -1;
|
var i = -1;
|
||||||
connections.map(function(c, idx) {
|
connections.map(function(c, idx) {
|
||||||
|
|||||||
@@ -196,6 +196,8 @@ pub trait InvokeUiCM: Send + Clone + 'static + Sized {
|
|||||||
fn update_voice_call_state(&self, client: &Client);
|
fn update_voice_call_state(&self, client: &Client);
|
||||||
|
|
||||||
fn file_transfer_log(&self, action: &str, log: &str);
|
fn file_transfer_log(&self, action: &str, log: &str);
|
||||||
|
|
||||||
|
fn update_port_forward(&self, id: i32, port_forward: String);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: InvokeUiCM> Deref for ConnectionManager<T> {
|
impl<T: InvokeUiCM> Deref for ConnectionManager<T> {
|
||||||
@@ -602,6 +604,17 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Data::UpdatePortForward(port_forward) => {
|
||||||
|
let updated = {
|
||||||
|
let mut clients = CLIENTS.write().unwrap();
|
||||||
|
clients.get_mut(&self.conn_id).map(|c| {
|
||||||
|
c.port_forward = port_forward.clone();
|
||||||
|
})
|
||||||
|
};
|
||||||
|
if updated.is_some() {
|
||||||
|
self.cm.ui_handler.update_port_forward(self.conn_id, port_forward);
|
||||||
|
}
|
||||||
|
}
|
||||||
Data::FS(mut fs) => {
|
Data::FS(mut fs) => {
|
||||||
if let ipc::FS::WriteBlock { id, file_num, data: _, compressed } = fs {
|
if let ipc::FS::WriteBlock { id, file_num, data: _, compressed } = fs {
|
||||||
if let Ok(bytes) = self.stream.next_raw().await {
|
if let Ok(bytes) = self.stream.next_raw().await {
|
||||||
|
|||||||
Reference in New Issue
Block a user