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.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 {

View File

@ -316,7 +316,7 @@ class SessionList: Reactor.Component {
<li #connect>{translate('Connect')}</li>
<li #transfer>{translate('Transfer File')}</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 #wol>{translate('WOL')}</li>
<div .separator />
@ -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) {

View File

@ -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());
}
}
}