Merge pull request #4814 from 21pages/fix
add error message judgement to set_force_relay
This commit is contained in:
commit
61135645d3
@ -55,11 +55,11 @@ use scrap::{
|
|||||||
|
|
||||||
use crate::is_keyboard_mode_supported;
|
use crate::is_keyboard_mode_supported;
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
|
||||||
use crate::{check_clipboard, ClipboardContext, CLIPBOARD_INTERVAL};
|
|
||||||
#[cfg(not(feature = "flutter"))]
|
#[cfg(not(feature = "flutter"))]
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
use crate::ui_session_interface::SessionPermissionConfig;
|
use crate::ui_session_interface::SessionPermissionConfig;
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
use crate::{check_clipboard, ClipboardContext, CLIPBOARD_INTERVAL};
|
||||||
|
|
||||||
pub use super::lang::*;
|
pub use super::lang::*;
|
||||||
|
|
||||||
@ -535,7 +535,7 @@ impl Client {
|
|||||||
let bytes = match res {
|
let bytes = match res {
|
||||||
Ok(bytes) => bytes,
|
Ok(bytes) => bytes,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
interface.set_force_relay(direct, false);
|
interface.set_force_relay(direct, false, err.to_string());
|
||||||
bail!("{}", err);
|
bail!("{}", err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1760,12 +1760,14 @@ impl LoginConfigHandler {
|
|||||||
msg_out
|
msg_out
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_force_relay(&mut self, direct: bool, received: bool) {
|
pub fn set_force_relay(&mut self, direct: bool, received: bool, err: String) {
|
||||||
self.force_relay = false;
|
self.force_relay = false;
|
||||||
if direct && !received {
|
if direct && !received {
|
||||||
let errno = errno::errno().0;
|
let errno = errno::errno().0;
|
||||||
// TODO: check mac and ios
|
// TODO: check mac and ios
|
||||||
if cfg!(windows) && errno == 10054 || !cfg!(windows) && errno == 104 {
|
if cfg!(windows) && (errno == 10054 || err.contains("10054"))
|
||||||
|
|| !cfg!(windows) && (errno == 104 || err.contains("104"))
|
||||||
|
{
|
||||||
self.force_relay = true;
|
self.force_relay = true;
|
||||||
self.set_option("force-always-relay".to_owned(), "Y".to_owned());
|
self.set_option("force-always-relay".to_owned(), "Y".to_owned());
|
||||||
}
|
}
|
||||||
@ -2315,11 +2317,11 @@ pub trait Interface: Send + Clone + 'static + Sized {
|
|||||||
async fn handle_test_delay(&mut self, t: TestDelay, peer: &mut Stream);
|
async fn handle_test_delay(&mut self, t: TestDelay, peer: &mut Stream);
|
||||||
|
|
||||||
fn get_login_config_handler(&self) -> Arc<RwLock<LoginConfigHandler>>;
|
fn get_login_config_handler(&self) -> Arc<RwLock<LoginConfigHandler>>;
|
||||||
fn set_force_relay(&self, direct: bool, received: bool) {
|
fn set_force_relay(&self, direct: bool, received: bool, err: String) {
|
||||||
self.get_login_config_handler()
|
self.get_login_config_handler()
|
||||||
.write()
|
.write()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.set_force_relay(direct, received);
|
.set_force_relay(direct, received, err);
|
||||||
}
|
}
|
||||||
fn is_force_relay(&self) -> bool {
|
fn is_force_relay(&self) -> bool {
|
||||||
self.get_login_config_handler().read().unwrap().force_relay
|
self.get_login_config_handler().read().unwrap().force_relay
|
||||||
|
@ -161,7 +161,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
|||||||
match res {
|
match res {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::error!("Connection closed: {}", err);
|
log::error!("Connection closed: {}", err);
|
||||||
self.handler.set_force_relay(direct, received);
|
self.handler.set_force_relay(direct, received, err.to_string());
|
||||||
let msgtype = "error";
|
let msgtype = "error";
|
||||||
let title = "Connection Error";
|
let title = "Connection Error";
|
||||||
let text = err.to_string();
|
let text = err.to_string();
|
||||||
|
@ -192,7 +192,7 @@ async fn connect_and_login_2(
|
|||||||
}
|
}
|
||||||
Ok(Some(Err(err))) => {
|
Ok(Some(Err(err))) => {
|
||||||
log::error!("Connection closed: {}", err);
|
log::error!("Connection closed: {}", err);
|
||||||
interface.set_force_relay(direct, received);
|
interface.set_force_relay(direct, received, err.to_string());
|
||||||
bail!("Connection closed: {}", err);
|
bail!("Connection closed: {}", err);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
Loading…
Reference in New Issue
Block a user