From a7c87a5f573def7620507f94b375996b9ff6f14c Mon Sep 17 00:00:00 2001 From: 21pages Date: Wed, 24 Aug 2022 16:23:36 +0800 Subject: [PATCH] option to enable force-always-relay Signed-off-by: 21pages --- src/client.rs | 2 +- src/ui/ab.tis | 3 +-- src/ui/remote.rs | 27 ++++++++++++++------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/client.rs b/src/client.rs index a73d4b60e..9f5338a6c 100644 --- a/src/client.rs +++ b/src/client.rs @@ -841,7 +841,7 @@ impl LoginConfigHandler { self.session_id = rand::random(); self.supported_encoding = None; self.restarting_remote_device = false; - self.force_relay = false; + self.force_relay = !self.get_option("force-always-relay").is_empty(); } pub fn should_auto_login(&self) -> String { diff --git a/src/ui/ab.tis b/src/ui/ab.tis index 28fa62352..658783623 100644 --- a/src/ui/ab.tis +++ b/src/ui/ab.tis @@ -316,7 +316,7 @@ class SessionList: Reactor.Component {
  • {translate('Connect')}
  • {translate('Transfer File')}
  • {translate('TCP Tunneling')}
  • - {false && !handler.using_public_server() &&
  • {svg_checkmark}{translate('Always connect via relay')}
  • } +
  • {svg_checkmark}{translate('Always connect via relay')}
  • RDP
  • {translate('WOL')}
  • @@ -396,7 +396,6 @@ class SessionList: Reactor.Component { if (el) { var force = handler.get_peer_option(id, "force-always-relay"); el.attributes.toggleClass("selected", force == "Y"); - el.attributes.toggleClass("line-through", force != "Y"); } var conn = this.$(menu #connect); if (conn) { diff --git a/src/ui/remote.rs b/src/ui/remote.rs index c9dd45888..25aacd26d 100644 --- a/src/ui/remote.rs +++ b/src/ui/remote.rs @@ -2085,18 +2085,18 @@ impl Remote { async fn send_opts_after_login(&self, peer: &mut Stream) { if let Some(opts) = self - .handler - .lc - .read() - .unwrap() - .get_option_message_after_login() - { - let mut misc = Misc::new(); - misc.set_option(opts); - let mut msg_out = Message::new(); - msg_out.set_misc(misc); - allow_err!(peer.send(&msg_out).await); - } + .handler + .lc + .read() + .unwrap() + .get_option_message_after_login() + { + let mut misc = Misc::new(); + misc.set_option(opts); + let mut msg_out = Message::new(); + msg_out.set_misc(misc); + allow_err!(peer.send(&msg_out).await); + } } async fn handle_msg_from_peer(&mut self, data: &[u8], peer: &mut Stream) -> bool { @@ -2714,9 +2714,10 @@ impl Interface for Handler { if direct && !received { let errno = errno::errno().0; log::info!("errno is {}", errno); - // TODO + // TODO: check mac and ios if cfg!(windows) && errno == 10054 || !cfg!(windows) && errno == 104 { lc.force_relay = true; + lc.set_option("force-always-relay".to_owned(), "Y".to_owned()); } } }