|
@@ -102,13 +102,11 @@ struct SocksParams {
|
|
|
/// and determining how to handle errors this or other threads receive.
|
|
/// and determining how to handle errors this or other threads receive.
|
|
|
async fn socket_updater(
|
|
async fn socket_updater(
|
|
|
str_params: SocksParams,
|
|
str_params: SocksParams,
|
|
|
- bootstrap: f64,
|
|
|
|
|
retry: f64,
|
|
retry: f64,
|
|
|
mut error_channel: ErrorChannelOut,
|
|
mut error_channel: ErrorChannelOut,
|
|
|
reader_channel: ReadSocketUpdaterIn,
|
|
reader_channel: ReadSocketUpdaterIn,
|
|
|
writer_channel: WriteSocketUpdaterIn,
|
|
writer_channel: WriteSocketUpdaterIn,
|
|
|
) -> FatalError {
|
|
) -> FatalError {
|
|
|
- let mut first_run: bool = true;
|
|
|
|
|
let retry = Duration::from_secs_f64(retry);
|
|
let retry = Duration::from_secs_f64(retry);
|
|
|
loop {
|
|
loop {
|
|
|
let socks_connection: Result<Socks5Stream<_>, MessengerError> =
|
|
let socks_connection: Result<Socks5Stream<_>, MessengerError> =
|
|
@@ -138,11 +136,6 @@ async fn socket_updater(
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if first_run {
|
|
|
|
|
- tokio::time::sleep(Duration::from_secs_f64(bootstrap)).await;
|
|
|
|
|
- first_run = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
let (rd, wr) = stream.into_inner().into_split();
|
|
let (rd, wr) = stream.into_inner().into_split();
|
|
|
reader_channel.send(rd);
|
|
reader_channel.send(rd);
|
|
|
writer_channel.send(wr);
|
|
writer_channel.send(wr);
|
|
@@ -169,7 +162,6 @@ async fn manage_conversation(config: Config) -> Result<(), MessengerError> {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
let mut state_machine = StateMachine::start(distributions, &mut rng);
|
|
let mut state_machine = StateMachine::start(distributions, &mut rng);
|
|
|
- let recipients: Vec<&str> = config.recipients.iter().map(String::as_str).collect();
|
|
|
|
|
|
|
|
|
|
let (reader_to_state, mut state_from_reader) = mpsc::unbounded_channel();
|
|
let (reader_to_state, mut state_from_reader) = mpsc::unbounded_channel();
|
|
|
let (state_to_writer, writer_from_state) = mpsc::unbounded_channel();
|
|
let (state_to_writer, writer_from_state) = mpsc::unbounded_channel();
|
|
@@ -186,13 +178,14 @@ async fn manage_conversation(config: Config) -> Result<(), MessengerError> {
|
|
|
tokio::spawn(writer(writer_from_state, write_socket_updater_out, errs_in));
|
|
tokio::spawn(writer(writer_from_state, write_socket_updater_out, errs_in));
|
|
|
tokio::spawn(socket_updater(
|
|
tokio::spawn(socket_updater(
|
|
|
str_params,
|
|
str_params,
|
|
|
- config.bootstrap,
|
|
|
|
|
config.retry,
|
|
config.retry,
|
|
|
errs_out,
|
|
errs_out,
|
|
|
read_socket_updater_in,
|
|
read_socket_updater_in,
|
|
|
write_socket_updater_in,
|
|
write_socket_updater_in,
|
|
|
));
|
|
));
|
|
|
|
|
|
|
|
|
|
+ tokio::time::sleep(Duration::from_secs_f64(config.bootstrap)).await;
|
|
|
|
|
+
|
|
|
let mut state_to_writer = StateToWriter {
|
|
let mut state_to_writer = StateToWriter {
|
|
|
channel: state_to_writer,
|
|
channel: state_to_writer,
|
|
|
};
|
|
};
|
|
@@ -205,7 +198,6 @@ async fn manage_conversation(config: Config) -> Result<(), MessengerError> {
|
|
|
&mut state_to_writer,
|
|
&mut state_to_writer,
|
|
|
&config.user,
|
|
&config.user,
|
|
|
&config.group,
|
|
&config.group,
|
|
|
- recipients.clone(),
|
|
|
|
|
&mut rng,
|
|
&mut rng,
|
|
|
)
|
|
)
|
|
|
.await
|
|
.await
|
|
@@ -217,7 +209,6 @@ async fn manage_conversation(config: Config) -> Result<(), MessengerError> {
|
|
|
&mut state_to_writer,
|
|
&mut state_to_writer,
|
|
|
&config.user,
|
|
&config.user,
|
|
|
&config.group,
|
|
&config.group,
|
|
|
- recipients.clone(),
|
|
|
|
|
&mut rng,
|
|
&mut rng,
|
|
|
)
|
|
)
|
|
|
.await
|
|
.await
|
|
@@ -230,7 +221,6 @@ async fn manage_conversation(config: Config) -> Result<(), MessengerError> {
|
|
|
struct Config {
|
|
struct Config {
|
|
|
user: String,
|
|
user: String,
|
|
|
group: String,
|
|
group: String,
|
|
|
- recipients: Vec<String>,
|
|
|
|
|
socks: String,
|
|
socks: String,
|
|
|
server: String,
|
|
server: String,
|
|
|
bootstrap: f64,
|
|
bootstrap: f64,
|