aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/mycelium
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-30 16:32:23 +0100
committertv <tv@krebsco.de>2026-10-30 16:32:23 +0100
commitf091fb2a9188f686e5b1f9012c510a1b3c8ad840 (patch)
tree8821dfe3c63535762a798b85dfe8c0d850a9df90 /src/transport/mycelium
parent0ee0cd19b7ceabf5d75e1b8fdd074a6e758bc6db (diff)
move transport config checks to respective modules
Diffstat (limited to 'src/transport/mycelium')
-rw-r--r--src/transport/mycelium/mod.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/transport/mycelium/mod.rs b/src/transport/mycelium/mod.rs
index 7abcced..20abee8 100644
--- a/src/transport/mycelium/mod.rs
+++ b/src/transport/mycelium/mod.rs
@@ -91,6 +91,26 @@ pub(crate) struct MyceliumTransport {
local_id: String,
}
+/// This transport's options, checked when the configuration is loaded
+/// (`config::Settings::check`): a daemon elsewhere (`mycelium-rest-url`) by a URL, and
+/// none of the options only a supervised one takes with it; a private network with
+/// both its key and its name.
+pub(crate) fn check(settings: &crate::config::Settings) -> Result<()> {
+ if let Some(url) = &settings.mycelium_rest_url {
+ Url::parse(url).with_context(|| format!("mycelium-rest-url {url:?}"))?;
+ if let Some((name, _)) = settings.supervised_only().iter().find(|(_, set)| *set) {
+ anyhow::bail!(
+ "{name} is for a supervised Mycelium daemon and can't be combined with mycelium-rest-url"
+ );
+ }
+ }
+ // A private network has both; one alone would be ignored or invented.
+ if settings.mycelium_network_key_file.is_some() != settings.mycelium_network_name.is_some() {
+ anyhow::bail!("mycelium-network-key-file and mycelium-network-name go together");
+ }
+ Ok(())
+}
+
/// The transport as `settings` configure it (`transport::start`): its daemon supervised
/// (started, which can take a while) or one running elsewhere. None if `stop` came
/// first.