mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-27 23:19:02 +08:00
Merge pull request #5449 from 21pages/fix
save ab password to recent PeerConfig when connected with it
This commit is contained in:
commit
1f0b9bf798
@ -1074,6 +1074,7 @@ pub struct LoginConfigHandler {
|
||||
pub direct: Option<bool>,
|
||||
pub received: bool,
|
||||
switch_uuid: Option<String>,
|
||||
pub save_ab_password_to_recent: bool,
|
||||
}
|
||||
|
||||
impl Deref for LoginConfigHandler {
|
||||
@ -1647,7 +1648,10 @@ impl LoginConfigHandler {
|
||||
log::debug!("remember password of {}", self.id);
|
||||
}
|
||||
} else {
|
||||
if !password0.is_empty() {
|
||||
if self.save_ab_password_to_recent {
|
||||
config.password = password;
|
||||
log::debug!("save ab password of {} to recent", self.id);
|
||||
} else if !password0.is_empty() {
|
||||
config.password = Default::default();
|
||||
log::debug!("remove password of {}", self.id);
|
||||
}
|
||||
@ -2173,6 +2177,7 @@ pub fn handle_login_error(
|
||||
err: &str,
|
||||
interface: &impl Interface,
|
||||
) -> bool {
|
||||
lc.write().unwrap().save_ab_password_to_recent = false;
|
||||
if err == LOGIN_MSG_PASSWORD_EMPTY {
|
||||
lc.write().unwrap().password = Default::default();
|
||||
interface.msgbox("input-password", "Password Required", "", "");
|
||||
@ -2252,7 +2257,11 @@ pub async fn handle_hash(
|
||||
.find_map(|p| if p.id == id { Some(p) } else { None })
|
||||
{
|
||||
if let Ok(hash) = base64::decode(p.hash.clone(), base64::Variant::Original) {
|
||||
password = hash;
|
||||
if !hash.is_empty() {
|
||||
password = hash;
|
||||
lc.write().unwrap().save_ab_password_to_recent = true;
|
||||
lc.write().unwrap().password = password.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -895,7 +895,7 @@ pub fn main_load_recent_peers_for_ab(filter: String) -> String {
|
||||
if !config::APP_DIR.read().unwrap().is_empty() {
|
||||
let peers: Vec<HashMap<&str, String>> = PeerConfig::peers(id_filters)
|
||||
.drain(..)
|
||||
.map(|(id, _, p)| peer_to_map_ab(id, p))
|
||||
.map(|(id, _, p)| peer_to_map(id, p))
|
||||
.collect();
|
||||
return serde_json::ser::to_string(&peers).unwrap_or("".to_owned());
|
||||
}
|
||||
|
@ -625,6 +625,7 @@ pub fn discover() {
|
||||
|
||||
#[cfg(feature = "flutter")]
|
||||
pub fn peer_to_map(id: String, p: PeerConfig) -> HashMap<&'static str, String> {
|
||||
use hbb_common::sodiumoxide::base64;
|
||||
HashMap::<&str, String>::from_iter([
|
||||
("id", id),
|
||||
("username", p.info.username.clone()),
|
||||
@ -634,20 +635,13 @@ pub fn peer_to_map(id: String, p: PeerConfig) -> HashMap<&'static str, String> {
|
||||
"alias",
|
||||
p.options.get("alias").unwrap_or(&"".to_owned()).to_owned(),
|
||||
),
|
||||
(
|
||||
"hash",
|
||||
base64::encode(p.password, base64::Variant::Original),
|
||||
),
|
||||
])
|
||||
}
|
||||
|
||||
#[cfg(feature = "flutter")]
|
||||
pub fn peer_to_map_ab(id: String, p: PeerConfig) -> HashMap<&'static str, String> {
|
||||
use hbb_common::sodiumoxide::base64;
|
||||
let mut m = peer_to_map(id, p.clone());
|
||||
m.insert(
|
||||
"hash",
|
||||
base64::encode(p.password, base64::Variant::Original),
|
||||
);
|
||||
m
|
||||
}
|
||||
|
||||
#[cfg(feature = "flutter")]
|
||||
pub fn peer_exists(id: &str) -> bool {
|
||||
PeerConfig::exists(id)
|
||||
|
Loading…
Reference in New Issue
Block a user