Compare commits
2 Commits
main
...
f9f3d77474
| Author | SHA1 | Date | |
|---|---|---|---|
| f9f3d77474 | |||
| 6154731576 |
@@ -1103,23 +1103,37 @@ impl Config {
|
||||
pub fn get_key_pair() -> KeyPair {
|
||||
// lock here to make sure no gen_keypair more than once
|
||||
// no use of CONFIG directly here to ensure no recursive calling in Config::load because of password dec which calling this function
|
||||
log::info!("breadcrumb: get_key_pair before KEY_PAIR.lock");
|
||||
let mut lock = KEY_PAIR.lock().unwrap();
|
||||
log::info!("breadcrumb: get_key_pair after KEY_PAIR.lock");
|
||||
if let Some(p) = lock.as_ref() {
|
||||
log::info!("breadcrumb: get_key_pair cache hit");
|
||||
return p.clone();
|
||||
}
|
||||
log::info!("breadcrumb: get_key_pair before Config::load_");
|
||||
let mut config = Config::load_::<Config>("");
|
||||
log::info!("breadcrumb: get_key_pair after Config::load_, key_pair_empty={}", config.key_pair.0.is_empty());
|
||||
if config.key_pair.0.is_empty() {
|
||||
log::info!("Generated new keypair for id: {}", config.id);
|
||||
log::info!("breadcrumb: get_key_pair before sign::gen_keypair");
|
||||
let (pk, sk) = sign::gen_keypair();
|
||||
log::info!("breadcrumb: get_key_pair after sign::gen_keypair");
|
||||
let key_pair = (sk.0.to_vec(), pk.0.into());
|
||||
config.key_pair = key_pair.clone();
|
||||
log::info!("breadcrumb: get_key_pair before thread::spawn for store");
|
||||
std::thread::spawn(|| {
|
||||
log::info!("breadcrumb: get_key_pair store-thread before CONFIG.write");
|
||||
let mut config = CONFIG.write().unwrap();
|
||||
log::info!("breadcrumb: get_key_pair store-thread after CONFIG.write");
|
||||
config.key_pair = key_pair;
|
||||
log::info!("breadcrumb: get_key_pair store-thread before config.store");
|
||||
config.store();
|
||||
log::info!("breadcrumb: get_key_pair store-thread after config.store");
|
||||
});
|
||||
log::info!("breadcrumb: get_key_pair after thread::spawn");
|
||||
}
|
||||
*lock = Some(config.key_pair.clone());
|
||||
log::info!("breadcrumb: get_key_pair returning");
|
||||
config.key_pair
|
||||
}
|
||||
|
||||
@@ -2944,6 +2958,7 @@ pub mod keys {
|
||||
pub const OPTION_USE_RAW_TCP_FOR_API: &str = "use-raw-tcp-for-api";
|
||||
pub const OPTION_ALLOW_HOSTNAME_AS_ID: &str = "allow-hostname-as-id";
|
||||
pub const OPTION_HIDE_POWERED_BY_ME: &str = "hide-powered-by-me";
|
||||
pub const OPTION_APP_ICON: &str = "app-icon";
|
||||
pub const OPTION_MAIN_WINDOW_ALWAYS_ON_TOP: &str = "main-window-always-on-top";
|
||||
pub const OPTION_DISABLE_CHANGE_PERMANENT_PASSWORD: &str = "disable-change-permanent-password";
|
||||
pub const OPTION_DISABLE_CHANGE_ID: &str = "disable-change-id";
|
||||
@@ -3154,6 +3169,7 @@ pub mod keys {
|
||||
OPTION_ALLOW_HOSTNAME_AS_ID,
|
||||
OPTION_REGISTER_DEVICE,
|
||||
OPTION_HIDE_POWERED_BY_ME,
|
||||
OPTION_APP_ICON,
|
||||
OPTION_MAIN_WINDOW_ALWAYS_ON_TOP,
|
||||
OPTION_FILE_TRANSFER_MAX_FILES,
|
||||
OPTION_DISABLE_CHANGE_PERMANENT_PASSWORD,
|
||||
|
||||
Reference in New Issue
Block a user