password: decrypt password when import user config

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2022-07-27 21:22:54 +08:00
parent 50d1b067e8
commit 9f22f55a1f
2 changed files with 15 additions and 2 deletions

View File

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