option to enable force-always-relay

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2022-08-24 16:23:36 +08:00
parent 0649a49d17
commit a7c87a5f57
3 changed files with 16 additions and 16 deletions

View File

@ -841,7 +841,7 @@ impl LoginConfigHandler {
self.session_id = rand::random(); self.session_id = rand::random();
self.supported_encoding = None; self.supported_encoding = None;
self.restarting_remote_device = false; 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 { pub fn should_auto_login(&self) -> String {

View File

@ -316,7 +316,7 @@ class SessionList: Reactor.Component {
<li #connect>{translate('Connect')}</li> <li #connect>{translate('Connect')}</li>
<li #transfer>{translate('Transfer File')}</li> <li #transfer>{translate('Transfer File')}</li>
<li #tunnel>{translate('TCP Tunneling')}</li> <li #tunnel>{translate('TCP Tunneling')}</li>
{false && !handler.using_public_server() && <li #force-always-relay><span>{svg_checkmark}</span>{translate('Always connect via relay')}</li>} <li #force-always-relay><span>{svg_checkmark}</span>{translate('Always connect via relay')}</li>
<li #rdp>RDP<EditRdpPort /></li> <li #rdp>RDP<EditRdpPort /></li>
<li #wol>{translate('WOL')}</li> <li #wol>{translate('WOL')}</li>
<div .separator /> <div .separator />
@ -396,7 +396,6 @@ class SessionList: Reactor.Component {
if (el) { if (el) {
var force = handler.get_peer_option(id, "force-always-relay"); var force = handler.get_peer_option(id, "force-always-relay");
el.attributes.toggleClass("selected", force == "Y"); el.attributes.toggleClass("selected", force == "Y");
el.attributes.toggleClass("line-through", force != "Y");
} }
var conn = this.$(menu #connect); var conn = this.$(menu #connect);
if (conn) { if (conn) {

View File

@ -2085,18 +2085,18 @@ impl Remote {
async fn send_opts_after_login(&self, peer: &mut Stream) { async fn send_opts_after_login(&self, peer: &mut Stream) {
if let Some(opts) = self if let Some(opts) = self
.handler .handler
.lc .lc
.read() .read()
.unwrap() .unwrap()
.get_option_message_after_login() .get_option_message_after_login()
{ {
let mut misc = Misc::new(); let mut misc = Misc::new();
misc.set_option(opts); misc.set_option(opts);
let mut msg_out = Message::new(); let mut msg_out = Message::new();
msg_out.set_misc(misc); msg_out.set_misc(misc);
allow_err!(peer.send(&msg_out).await); allow_err!(peer.send(&msg_out).await);
} }
} }
async fn handle_msg_from_peer(&mut self, data: &[u8], peer: &mut Stream) -> bool { 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 { if direct && !received {
let errno = errno::errno().0; let errno = errno::errno().0;
log::info!("errno is {}", errno); log::info!("errno is {}", errno);
// TODO // TODO: check mac and ios
if cfg!(windows) && errno == 10054 || !cfg!(windows) && errno == 104 { if cfg!(windows) && errno == 10054 || !cfg!(windows) && errno == 104 {
lc.force_relay = true; lc.force_relay = true;
lc.set_option("force-always-relay".to_owned(), "Y".to_owned());
} }
} }
} }