From 7e680a3a669b0ecf5d8f4237899b0825659cc315 Mon Sep 17 00:00:00 2001 From: ppom Date: Fri, 14 Nov 2025 12:00:00 +0100 Subject: [PATCH] Remove shared_secret option --- .../reaction-plugin-cluster/src/cluster.rs | 13 +++------- .../reaction-plugin-cluster/src/endpoint.rs | 3 --- plugins/reaction-plugin-cluster/src/main.rs | 25 ++----------------- 3 files changed, 6 insertions(+), 35 deletions(-) diff --git a/plugins/reaction-plugin-cluster/src/cluster.rs b/plugins/reaction-plugin-cluster/src/cluster.rs index ddce02b..dd17465 100644 --- a/plugins/reaction-plugin-cluster/src/cluster.rs +++ b/plugins/reaction-plugin-cluster/src/cluster.rs @@ -51,10 +51,6 @@ impl Cluster { let (endpoint_addr_tx, connection_rx) = EndpointManager::new(endpoint, stream.name.clone(), stream.nodes.len()); - for node in stream.nodes.values() { - endpoint_addr_tx.send(node.clone()).await.unwrap(); - } - let this = Self { // No connection for now connections: Default::default(), @@ -71,18 +67,17 @@ impl Cluster { } async fn task(mut self) { + // Ask connections for all nodes + for node in self.stream.nodes.values() { + self.endpoint_addr_tx.send(node.clone()).await.unwrap(); + } let action_rx = self.spawn_actions(); // Ok donc là il faut : - // - Que je réessaie plus tard les connections qui ont raté - // - Que j'accepte des nouvelles connections // - Que j'ai une queue par noeud // - Que chaque élément de la queue puisse timeout // - Que j'envoie les messages de mes actions dans toutes les queues - // // - Que j'écoute les messages de mes pairs et que je les renvoie à mon stream - // - // Et que je gère l'authentification en début de connection } fn spawn_actions(&mut self) -> mpsc::Receiver<(Exec, bool)> { diff --git a/plugins/reaction-plugin-cluster/src/endpoint.rs b/plugins/reaction-plugin-cluster/src/endpoint.rs index 1e51e46..cd803e3 100644 --- a/plugins/reaction-plugin-cluster/src/endpoint.rs +++ b/plugins/reaction-plugin-cluster/src/endpoint.rs @@ -40,14 +40,12 @@ pub struct EndpointManager { endpoint_addr_rx: mpsc::Receiver, /// Connection sender to the [`crate::Cluster`] connection_tx: mpsc::Sender, - shared_secret: String, } impl EndpointManager { pub fn new( endpoint: Endpoint, cluster_name: String, - shared_secret: String, cluster_size: usize, ) -> (mpsc::Sender, mpsc::Receiver) { let (tx1, rx1) = mpsc::channel(cluster_size); @@ -61,7 +59,6 @@ impl EndpointManager { all_connections: Default::default(), endpoint_addr_rx: rx1, connection_tx: tx2, - shared_secret, } .task() .await diff --git a/plugins/reaction-plugin-cluster/src/main.rs b/plugins/reaction-plugin-cluster/src/main.rs index d112ea7..fcfda25 100644 --- a/plugins/reaction-plugin-cluster/src/main.rs +++ b/plugins/reaction-plugin-cluster/src/main.rs @@ -10,7 +10,7 @@ use reaction_plugin::{ }; use remoc::{rch::mpsc, rtc}; use serde::{Deserialize, Serialize}; -use tokio::{fs, sync::oneshot}; +use tokio::sync::oneshot; mod cluster; mod endpoint; @@ -45,14 +45,9 @@ struct StreamOptions { #[serde(default = "ipv4_unspecified")] bind_ipv4: Option, /// The IPv6 to bind to. Defaults to 0.0.0.0. - /// Set to `null` to use IPv6 only. + /// Set to `null` to use IPv4 only. #[serde(default = "ipv6_unspecified")] bind_ipv6: Option, - /// The secret that permits to join the cluster. - shared_secret: Option, - /// The secret that permits to join the cluster, as a file. - /// Beginning and ending whitespace will be trimmed. - shared_secret_file: Option, /// Other nodes which are part of the cluster. nodes: Vec, /// Max duration before we drop pending messages to a node we can't connect to. @@ -72,7 +67,6 @@ struct StreamInit { listen_port: u16, bind_ipv4: Option, bind_ipv6: Option, - shared_secret: String, secret_key: SecretKey, message_timeout: Duration, nodes: BTreeMap, @@ -127,20 +121,6 @@ impl PluginInfo for Plugin { let options: StreamOptions = serde_json::from_value(config.into()) .map_err(|err| format!("invalid options: {err}"))?; - let shared_secret = if let Some(shared_secret) = options.shared_secret { - shared_secret - } else if let Some(shared_secret_file) = &options.shared_secret_file { - fs::read_to_string(shared_secret_file) - .await - .map_err(|err| { - format!("can't access shared_secret_file {shared_secret_file}: {err}") - })? - .trim() - .to_owned() - } else { - return Err("missing shared secret: either shared_secret or shared_secret_file must be provided".into()); - }; - let mut nodes = BTreeMap::default(); let message_timeout = parse_duration(&options.message_timeout) @@ -179,7 +159,6 @@ impl PluginInfo for Plugin { listen_port: options.listen_port, bind_ipv4: options.bind_ipv4, bind_ipv6: options.bind_ipv6, - shared_secret, secret_key, message_timeout, nodes,