diff options
| author | tv <tv@krebsco.de> | 2026-11-30 18:13:31 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-30 18:13:31 +0000 |
| commit | ae4c3358e1e216d0a152ad591e04faa106b4cefa (patch) | |
| tree | e58d81708b936c868005a9bc98c81cc8fa0c038b /src/config | |
| parent | 4deaec75e49b7f0853c2b82bbcce129d19dcff51 (diff) | |
continuum node-id needs none of a node's configuration
It was answered after the node's configuration was read and checked,
which asked for htpasswd, a node key file and the rest: what a party's
founders don't have yet as they ask for their nodes' IDs, and the
guides tell them to run it alone. It is answered before now
(config::asked_node_id).
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/mod.rs | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 7b17f5d..e68b60c 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1617,7 +1617,7 @@ fn command() -> Command { with_options(::config::arguments::with_print_config(command), OPTIONS) } -/// `continuum node-id FILE`: the node ID of the key in `FILE` (`Loaded::node_id`). +/// `continuum node-id FILE`: the node ID of the key in `FILE` (`asked_node_id`). const NODE_ID: &str = "node-id"; /// The configuration, and where each value set came from (absent: default). @@ -1628,9 +1628,6 @@ pub(crate) struct Loaded { pub(crate) files: Vec<PathBuf>, /// `--print-config`: print [`Loaded::report`] and exit. pub(crate) print_only: bool, - /// `node-id FILE [--create]`: print the node ID of the key `FILE` holds, made there - /// with `--create` where there is none, and exit. - pub(crate) node_id: Option<(PathBuf, bool)>, } impl Loaded { @@ -1700,22 +1697,30 @@ pub(crate) fn load() -> Result<Loaded> { ::config::arguments::refuse_gone(std::env::args().skip(1), &SCHEMA)?; let matches = command().get_matches(); let print_only = ::config::arguments::prints_config(&matches); - let node_id = matches.subcommand_matches(NODE_ID).map(|sub| { - let file = sub.get_one::<String>("file").expect("required"); - (PathBuf::from(file), sub.get_flag("create")) - }); - if print_only || node_id.is_some() { - // Logs go to stdout too: the report or the node ID goes there alone (the report - // says where each value came from anyway). + if print_only { + // Logs go to stdout too: the report goes there alone (it says where each value + // came from anyway). let _ = crate::logging::set_filter("off"); } let (merged, files) = merged(&matches, &SCHEMA, &[])?; let mut loaded = resolve(merged, files)?; loaded.print_only = print_only; - loaded.node_id = node_id; Ok(loaded) } +/// `node-id FILE [--create]`, where the command line asks for it: the file whose key's +/// node ID to print, made there with `--create` where there is none. Asked before +/// the configuration is read: it needs none of a node's, which a party's founders +/// don't have yet as they ask for their nodes' IDs. +pub(crate) fn asked_node_id() -> Option<(PathBuf, bool)> { + let matches = command().get_matches(); + let sub = matches.subcommand_matches(NODE_ID)?; + let file = sub.get_one::<String>("file").expect("required"); + // Logs go to stdout too: the node ID goes there alone. + let _ = crate::logging::set_filter("off"); + Some((PathBuf::from(file), sub.get_flag("create"))) +} + /// HyParView's active view, where `neighbours` isn't set: the paper's, for swarms of up /// to about 10 000 members (its fanout of 4, plus one). const HYPARVIEW_NEIGHBOURS: usize = 5; @@ -1821,7 +1826,6 @@ fn resolve(merged: Layer, files: Vec<PathBuf>) -> Result<Loaded> { .collect(), files, print_only: false, - node_id: None, }) } |
