|
@@ -338,37 +338,35 @@ fn process_config(
|
|
|
);
|
|
|
|
|
|
for recipient in conversation.recipients.iter() {
|
|
|
- let state_to_writer = if !recipient_map.contains_key(recipient) {
|
|
|
- let (state_to_writer, writer_from_state) = mpsc::unbounded_channel();
|
|
|
- let mut reader_to_states = HashMap::new();
|
|
|
- reader_to_states.insert(conversation.group.clone(), reader_to_state.clone());
|
|
|
- let address = hosts_map
|
|
|
- .get(recipient.as_str())
|
|
|
- .unwrap_or_else(|| panic!("recipient not in hosts file: {}", recipient));
|
|
|
- let str_params = SocksParams {
|
|
|
- socks: config.socks.clone(),
|
|
|
- target: address.to_string(),
|
|
|
- user: config.user.clone(),
|
|
|
- recipient: recipient.clone(),
|
|
|
- };
|
|
|
- let for_io = ForIoThreads {
|
|
|
- state_to_writer: state_to_writer.clone(),
|
|
|
- writer_from_state,
|
|
|
- reader_to_states,
|
|
|
- str_params,
|
|
|
- retry: conversation.retry,
|
|
|
- };
|
|
|
- recipient_map.insert(recipient.clone(), for_io);
|
|
|
- state_to_writer
|
|
|
- } else {
|
|
|
- let for_io = recipient_map.get_mut(recipient).unwrap();
|
|
|
- if !for_io.reader_to_states.contains_key(&conversation.group) {
|
|
|
- for_io
|
|
|
- .reader_to_states
|
|
|
- .insert(conversation.group.clone(), reader_to_state.clone());
|
|
|
- }
|
|
|
- for_io.state_to_writer.clone()
|
|
|
- };
|
|
|
+ let for_io = recipient_map
|
|
|
+ .entry(recipient.to_string())
|
|
|
+ .and_modify(|e| {
|
|
|
+ e.reader_to_states
|
|
|
+ .entry(conversation.group.clone())
|
|
|
+ .or_insert_with(|| reader_to_state.clone());
|
|
|
+ })
|
|
|
+ .or_insert_with(|| {
|
|
|
+ let (state_to_writer, writer_from_state) = mpsc::unbounded_channel();
|
|
|
+ let mut reader_to_states = HashMap::new();
|
|
|
+ reader_to_states.insert(conversation.group.clone(), reader_to_state.clone());
|
|
|
+ let address = hosts_map
|
|
|
+ .get(recipient.as_str())
|
|
|
+ .unwrap_or_else(|| panic!("recipient not in hosts file: {}", recipient));
|
|
|
+ let str_params = SocksParams {
|
|
|
+ socks: config.socks.clone(),
|
|
|
+ target: address.to_string(),
|
|
|
+ user: config.user.clone(),
|
|
|
+ recipient: recipient.clone(),
|
|
|
+ };
|
|
|
+ ForIoThreads {
|
|
|
+ state_to_writer,
|
|
|
+ writer_from_state,
|
|
|
+ reader_to_states,
|
|
|
+ str_params,
|
|
|
+ retry: conversation.retry,
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let state_to_writer = for_io.state_to_writer.clone();
|
|
|
conversation_recipient_map.insert(
|
|
|
recipient.clone(),
|
|
|
StateToWriter {
|