Skip to content

Commit

Permalink
fix(derper): update config to auto generate keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Arqu committed Oct 9, 2023
1 parent 898b0f7 commit d61ea36
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions iroh-net/src/bin/derper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,23 @@ impl Config {
if !path.as_ref().is_file() {
bail!("config-path must be a valid toml file");
}
let config_ser = tokio::fs::read_to_string(path)
let mut config_ser = tokio::fs::read_to_string(&path)
.await
.context("unable to read config")?;
let config = toml::from_str(&config_ser).context("unable to decode config")?;
let secret_key_injected = false;
if !config_ser.contains("secret_key") {
config_ser = format!(
r#"
secret_key = "{}"
{}"#,
SecretKey::generate(),
config_ser
);
}
let config: Self = toml::from_str(&config_ser).context("unable to decode config")?;
if secret_key_injected {
config.write_to_file(path).await?;
}

Ok(config)
}
Expand Down

0 comments on commit d61ea36

Please sign in to comment.