Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(derper): update config to auto generate keys #1599

Merged
merged 3 commits into from
Oct 9, 2023
Merged

Conversation

Arqu
Copy link
Collaborator

@Arqu Arqu commented Oct 9, 2023

Description

Deploying a derper node is a bit cumbersome right now if you don't run with default config. You have to provide a secret_key but have no easy path to generate one so either you dance to create a fresh config and then modify it or need to use some external thing to generate keys for you. Either way it's cumbersome.

This just adds an extra handler to inject a secret key if not present already in the supplied config.

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.

@Arqu Arqu self-assigned this Oct 9, 2023
.await
.context("unable to read config")?;
let config = toml::from_str(&config_ser).context("unable to decode config")?;
let mut secret_key_injected = false;
if !config_ser.contains("secret_key") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would strongly prefer to inject this after toml parsing, there is actually a nice way to do this.

#[serde(default = "SecretKey::generate")]
secret_key: SecretKey,

will do exactly that.

Ref https://serde.rs/field-attrs.html#default

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swear serde is more powerful than any AI we have so far :D

let config = toml::from_str(&config_ser).context("unable to decode config")?;
let config: Self = toml::from_str(&config_ser).context("unable to decode config")?;
if !config_ser.contains("secret_key") {
config.write_to_file(path).await?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one last complain, lets add a log line for this event

@Arqu Arqu added this pull request to the merge queue Oct 9, 2023
Merged via the queue into main with commit 8fb46d4 Oct 9, 2023
15 checks passed
@b5 b5 added this to the v0.7.0 milestone Oct 10, 2023
@dignifiedquire dignifiedquire deleted the arqu/derp_deploy branch November 1, 2023 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants