mirror of
https://framagit.org/ppom/reaction
synced 2026-03-14 20:55:47 +01:00
Remove shared_secret option
This commit is contained in:
parent
9235873084
commit
7e680a3a66
3 changed files with 6 additions and 35 deletions
|
|
@ -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)> {
|
||||
|
|
|
|||
|
|
@ -40,14 +40,12 @@ pub struct EndpointManager {
|
|||
endpoint_addr_rx: mpsc::Receiver<EndpointAddr>,
|
||||
/// Connection sender to the [`crate::Cluster`]
|
||||
connection_tx: mpsc::Sender<Connection>,
|
||||
shared_secret: String,
|
||||
}
|
||||
|
||||
impl EndpointManager {
|
||||
pub fn new(
|
||||
endpoint: Endpoint,
|
||||
cluster_name: String,
|
||||
shared_secret: String,
|
||||
cluster_size: usize,
|
||||
) -> (mpsc::Sender<EndpointAddr>, mpsc::Receiver<Connection>) {
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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<Ipv4Addr>,
|
||||
/// 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<Ipv6Addr>,
|
||||
/// The secret that permits to join the cluster.
|
||||
shared_secret: Option<String>,
|
||||
/// The secret that permits to join the cluster, as a file.
|
||||
/// Beginning and ending whitespace will be trimmed.
|
||||
shared_secret_file: Option<String>,
|
||||
/// Other nodes which are part of the cluster.
|
||||
nodes: Vec<NodeOption>,
|
||||
/// 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<Ipv4Addr>,
|
||||
bind_ipv6: Option<Ipv6Addr>,
|
||||
shared_secret: String,
|
||||
secret_key: SecretKey,
|
||||
message_timeout: Duration,
|
||||
nodes: BTreeMap<PublicKey, EndpointAddr>,
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue