mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-29 08:19:05 +08:00
password: decrypt password when import user config
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
50d1b067e8
commit
9f22f55a1f
@ -228,6 +228,13 @@ impl Config2 {
|
||||
config
|
||||
}
|
||||
|
||||
pub fn decrypt_password(&mut self) {
|
||||
if let Some(mut socks) = self.socks.clone() {
|
||||
socks.password = decrypt_str_or_original(&socks.password, PASSWORD_ENC_VERSION).0;
|
||||
self.socks = Some(socks);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file() -> PathBuf {
|
||||
Config::file_("2")
|
||||
}
|
||||
@ -299,6 +306,10 @@ impl Config {
|
||||
config
|
||||
}
|
||||
|
||||
pub fn decrypt_password(&mut self) {
|
||||
self.password = decrypt_str_or_original(&self.password, PASSWORD_ENC_VERSION).0;
|
||||
}
|
||||
|
||||
fn store(&self) {
|
||||
let mut config = self.clone();
|
||||
config.password = encrypt_str_or_original(&config.password, PASSWORD_ENC_VERSION);
|
||||
|
@ -171,18 +171,20 @@ fn import_config(path: &str) {
|
||||
let path2 = std::path::Path::new(&path2);
|
||||
let path = std::path::Path::new(path);
|
||||
log::info!("import config from {:?} and {:?}", path, path2);
|
||||
let config: Config = load_path(path.into());
|
||||
let mut config: Config = load_path(path.into());
|
||||
if config.id.is_empty() || config.key_pair.0.is_empty() {
|
||||
log::info!("Empty source config, skipped");
|
||||
return;
|
||||
}
|
||||
if get_modified_time(&path) > get_modified_time(&Config::file()) {
|
||||
config.decrypt_password();
|
||||
if Config::set(config) {
|
||||
log::info!("config written");
|
||||
}
|
||||
}
|
||||
let config2: Config2 = load_path(path2.into());
|
||||
let mut config2: Config2 = load_path(path2.into());
|
||||
if get_modified_time(&path2) > get_modified_time(&Config2::file()) {
|
||||
config2.decrypt_password();
|
||||
if Config2::set(config2) {
|
||||
log::info!("config2 written");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user