summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-26 04:43:09 +0100
committertv <tv@krebsco.de>2026-10-26 04:43:09 +0100
commit2646e19cf29b410f542097d75e620116c96da96b (patch)
treec7edd4dcca10037dbddbb4148512d97463125b9f /src
parent33435ef8a8a4f33d043180cfaf9a3d2e7f606579 (diff)
cleanup mycelium daemon
Diffstat (limited to 'src')
-rw-r--r--src/main.rs3
-rw-r--r--src/transport/mod.rs1
-rw-r--r--src/transport/mycelium/daemon.rs (renamed from src/transport/daemon.rs)54
-rw-r--r--src/transport/mycelium/mod.rs (renamed from src/transport/mycelium.rs)16
4 files changed, 21 insertions, 53 deletions
diff --git a/src/main.rs b/src/main.rs
index ece72ac..a79c6a2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -35,8 +35,7 @@ use api::auth::AuthState;
use document::replica::Epoch;
use swarm::bootstrap;
use transport::Transport;
-use transport::daemon::{MyceliumSetup, MyceliumSpawnConfig};
-use transport::mycelium;
+use transport::mycelium::{self, MyceliumSetup, MyceliumSpawnConfig};
#[tokio::main]
async fn main() -> Result<()> {
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index c45d117..14c5ee4 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -10,7 +10,6 @@ use std::pin::Pin;
pub use crate::document::replica::Epoch;
-pub mod daemon;
pub mod firewall;
pub mod mycelium;
#[cfg(test)]
diff --git a/src/transport/daemon.rs b/src/transport/mycelium/daemon.rs
index eceeb4d..80b6be5 100644
--- a/src/transport/daemon.rs
+++ b/src/transport/mycelium/daemon.rs
@@ -34,9 +34,6 @@ pub struct MyceliumSpawnConfig {
pub network_key_file: Option<PathBuf>,
pub network_name: String,
pub tcp_port: Option<u16>,
- pub api_port: Option<u16>,
- pub rpc_port: Option<u16>,
- pub discovery_port: Option<u16>,
pub peers: Vec<String>,
}
@@ -48,9 +45,6 @@ impl Default for MyceliumSpawnConfig {
network_key_file: None,
network_name: "something".to_string(),
tcp_port: None,
- api_port: None,
- rpc_port: None,
- discovery_port: None,
peers: vec!["tls://127.0.0.1:9651".to_string()],
}
}
@@ -101,17 +95,10 @@ impl MyceliumSetup {
key: KeySource::Path(net_key_path),
});
- let supervised_node = SupervisedMycelium::spawn(
- key,
- private_net_config,
- config.tcp_port,
- config.api_port,
- config.rpc_port,
- config.discovery_port,
- &config.peers,
- )
- .await
- .context("Failed to securely bootstrap embedded Mycelium background worker")?;
+ let supervised_node =
+ SupervisedMycelium::spawn(key, private_net_config, config.tcp_port, &config.peers)
+ .await
+ .context("Failed to securely bootstrap embedded Mycelium background worker")?;
let resolved_url = Url::parse(&format!(
"http://127.0.0.1:{}",
@@ -140,7 +127,6 @@ pub struct MyceliumNodeConfig {
pub tcp_port: u16,
pub api_port: u16,
pub rpc_port: u16,
- pub discovery_port: Option<u16>,
pub private_network: Option<String>,
}
@@ -156,9 +142,6 @@ impl SupervisedMycelium {
node_key: KeySource,
private_network: Option<PrivateNetworkConfig>,
explicit_tcp: Option<u16>,
- explicit_api: Option<u16>,
- explicit_rpc: Option<u16>,
- explicit_discovery_port: Option<u16>,
peers: &[String],
) -> Result<Self> {
// Linux only: keys are handed over in memory (memfd, never on disk), and the
@@ -174,26 +157,14 @@ impl SupervisedMycelium {
Some(p) => p,
None => Self::find_available_port().context("Failed to allocate TCP wire port")?,
};
- let api_port = match explicit_api {
- Some(p) => p,
- None => Self::find_available_port().context("Failed to allocate API port")?,
- };
- let rpc_port = match explicit_rpc {
- Some(p) => p,
- None => Self::find_available_port().context("Failed to allocate JSON-RPC port")?,
- };
- let discovery_port = match explicit_discovery_port {
- Some(0) => Some(
- Self::find_available_port().context("Failed to allocate peer discovery port")?,
- ),
- p => p,
- };
+ // Local only, so any free port will do.
+ let api_port = Self::find_available_port().context("Failed to allocate API port")?;
+ let rpc_port = Self::find_available_port().context("Failed to allocate JSON-RPC port")?;
let config = MyceliumNodeConfig {
tcp_port,
api_port,
rpc_port,
- discovery_port,
private_network: private_network.as_ref().map(|pn| pn.name.clone()),
};
@@ -259,12 +230,8 @@ impl SupervisedMycelium {
.arg(&rpc_addr)
.arg("--no-tun");
- if let Some(ref discovery_port) = config.discovery_port {
- cmd.arg("--peer-discovery-port")
- .arg(discovery_port.to_string());
- } else {
- cmd.arg("--disable-peer-discovery");
- }
+ // Peers come from `--mycelium-peers`; no local multicast discovery.
+ cmd.arg("--disable-peer-discovery");
if let Some(ref net_name) = config.private_network {
cmd.arg("--network-name").arg(net_name);
@@ -286,7 +253,7 @@ impl SupervisedMycelium {
.spawn()
.context("Failed to execute mycelium process daemon")?;
- // 1. FIXED: Pass-through streaming for child process STDOUT
+ // Its output goes where ours does.
if let Some(mut stdout) = child.stdout.take() {
tokio::spawn(async move {
let mut host_stdout = tokio::io::stdout();
@@ -294,7 +261,6 @@ impl SupervisedMycelium {
});
}
- // 2. FIXED: Pass-through streaming for child process STDERR
if let Some(mut stderr) = child.stderr.take() {
tokio::spawn(async move {
let mut host_stderr = tokio::io::stderr();
diff --git a/src/transport/mycelium.rs b/src/transport/mycelium/mod.rs
index d8d8689..cbae567 100644
--- a/src/transport/mycelium.rs
+++ b/src/transport/mycelium/mod.rs
@@ -7,10 +7,13 @@ use std::time::Duration;
use thiserror::Error;
use url::Url;
-use super::daemon::MyceliumSetup;
use crate::transport::wire;
use crate::transport::{EncodedMessage, MessageHandler, ParsedMessage, Transport};
+pub mod daemon;
+
+pub use daemon::{MyceliumSetup, MyceliumSpawnConfig};
+
const MYCELIUM_POLL_TIMEOUT_SECS: u64 = 300;
/// The one Mycelium topic all of continuum's messages travel on; what a message is, its
@@ -54,11 +57,12 @@ fn is_pubkey(s: &str) -> bool {
}
pub struct MyceliumTransport {
- // Wrap your zero-allocation lifecycle supervisor directly inside the driver plane
- pub setup: tokio::sync::Mutex<MyceliumSetup>,
- pub client: reqwest::Client,
- pub poll_client: reqwest::Client,
- pub messages_endpoint: Url,
+ /// The daemon, kept to wait for its exit.
+ setup: tokio::sync::Mutex<MyceliumSetup>,
+ client: reqwest::Client,
+ /// For the long-polling inbox (its timeout is longer).
+ poll_client: reqwest::Client,
+ messages_endpoint: Url,
pubkey_basepath: Url,
local_id: String,
}