diff options
| author | Catlinman <contact@catlinman.com> | 2020-03-22 19:10:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-22 19:10:21 +0100 |
| commit | ede6ee22b74e62572e32a9bac357c7b29ead2800 (patch) | |
| tree | 36cc683c71d73dd7bec019081827e36dd329a6ac /src/main.rs | |
| parent | 08794f7f7bfd226c4b68b141be14e2405ce61d03 (diff) | |
| parent | 595232693c270e8c6c85d04ce341676e96682c6f (diff) | |
| download | pokebot-ede6ee22b74e62572e32a9bac357c7b29ead2800.tar.gz pokebot-ede6ee22b74e62572e32a9bac357c7b29ead2800.zip | |
Merge pull request #48 from Mavulp/security-level
Add flag to increase identity security levels
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 6442005..4fd2b0c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,6 +32,9 @@ pub struct Args { help = "Generate 'count' identities" )] gen_id_count: Option<u8>, + /// Increases the security level of all identities in the config file + #[structopt(short, long = "increase-security-level")] + wanted_level: Option<u8>, #[structopt( short = "a", long = "address", @@ -103,6 +106,27 @@ fn run() -> Result<(), Box<dyn std::error::Error>> { return Ok(()); } + if let Some(level) = args.wanted_level { + if let Some(id) = &mut config.id { + info!("Upgrading master identity"); + id.upgrade_level(level).expect("can upgrade level"); + } + + if let Some(ids) = &mut config.ids { + let len = ids.len(); + for (i, id) in ids.iter_mut().enumerate() { + info!("Upgrading bot identity {}/{}", i + 1, len); + id.upgrade_level(level).expect("can upgrade level"); + } + } + + let toml = toml::to_string(&config)?; + let mut file = File::create(&args.config_path)?; + file.write_all(toml.as_bytes())?; + + return Ok(()); + } + if config.id.is_none() || config.ids.is_none() { error!("Failed to find required identites, try running with `-g`"); return Ok(()); |
