|
@@ -327,7 +327,6 @@ async fn socket_updater(
|
|
|
/// Spawns all other threads for this conversation.
|
|
|
async fn manage_conversation(config: FullConfig) -> Result<(), MessengerError> {
|
|
|
let mut rng = Xoshiro256PlusPlus::from_entropy();
|
|
|
- let distributions: Distributions = config.distributions.try_into()?;
|
|
|
|
|
|
let message_server_params = SocksParams {
|
|
|
socks: config.socks.clone(),
|
|
@@ -343,7 +342,7 @@ async fn manage_conversation(config: FullConfig) -> Result<(), MessengerError> {
|
|
|
recipient: config.group.clone(),
|
|
|
};
|
|
|
|
|
|
- let mut state_machine = StateMachine::start(distributions, &mut rng);
|
|
|
+ let mut state_machine = StateMachine::start(config.distributions, &mut rng);
|
|
|
|
|
|
let (reader_to_state, mut state_from_reader) = mpsc::unbounded_channel();
|
|
|
let (state_to_writer, writer_from_state) = mpsc::unbounded_channel();
|
|
@@ -431,7 +430,7 @@ struct FullConfig {
|
|
|
web_server: String,
|
|
|
bootstrap: f64,
|
|
|
retry: f64,
|
|
|
- distributions: ConfigDistributions,
|
|
|
+ distributions: Distributions,
|
|
|
}
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
@@ -464,7 +463,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
for config_file in args.flat_map(|a| glob::glob(a.as_str()).unwrap()) {
|
|
|
let yaml_s = std::fs::read_to_string(config_file?)?;
|
|
|
let config: Config = serde_yaml::from_str(&yaml_s)?;
|
|
|
+ let default_dists: Distributions = config.distributions.try_into()?;
|
|
|
for conversation in config.conversations.into_iter() {
|
|
|
+ let distributions: Distributions = match conversation.distributions {
|
|
|
+ Some(dists) => dists.try_into()?,
|
|
|
+ None => default_dists.clone(),
|
|
|
+ };
|
|
|
let filled_conversation = FullConfig {
|
|
|
user: config.user.clone(),
|
|
|
group: conversation.group,
|
|
@@ -477,9 +481,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
.unwrap_or_else(|| config.web_server.clone()),
|
|
|
bootstrap: conversation.bootstrap.unwrap_or(config.bootstrap),
|
|
|
retry: conversation.retry.unwrap_or(config.retry),
|
|
|
- distributions: conversation
|
|
|
- .distributions
|
|
|
- .unwrap_or_else(|| config.distributions.clone()),
|
|
|
+ distributions,
|
|
|
};
|
|
|
let handle: task::JoinHandle<Result<(), MessengerError>> =
|
|
|
tokio::spawn(manage_conversation(filled_conversation));
|