1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use serde::{Deserialize, Serialize};
use structopt::StructOpt;
use crate::config::{AuthOpt, CommonOpt};
#[derive(Debug, StructOpt, Clone, Deserialize, Serialize)]
pub struct BridgeTestOpt {
#[structopt(flatten)]
pub common: CommonOpt,
#[structopt(flatten)]
pub auth: AuthOpt,
#[structopt(long)]
/// Whether to use TCP
use_tcp: bool,
}
/// Entry point to the bridgetest subcommand, which sweeps through all available bridges and displays their reachability and performance in table.
pub async fn main_bridgetest(_opt: BridgeTestOpt) -> anyhow::Result<()> {
todo!()
// let exits = CACHED_BINDER_CLIENT.get_summary().await?.exits;
// for exit in exits {
// log::debug!(
// "EXIT: {} ({}-{})",
// exit.hostname,
// exit.country_code,
// exit.city_code
// );
// let bridges = CACHED_BINDER_CLIENT.get_bridges(&exit.hostname).await?;
// let proto = if opt.use_tcp {
// sosistab::Protocol::DirectTcp
// } else {
// sosistab::Protocol::DirectUdp
// };
// let iter = bridges
// .into_iter()
// .map(|bridge| {
// let proto = proto.clone();
// smolscale::spawn(async move {
// let start = Instant::now();
// let sess = sosistab::ClientConfig::new(
// proto,
// bridge.endpoint,
// bridge.sosistab_key,
// Default::default(),
// )
// .connect()
// .timeout(Duration::from_secs(5))
// .await;
// match sess {
// Some(Ok(_)) => {
// log::debug!(">>> {} ({:?})", bridge.endpoint, start.elapsed())
// }
// Some(Err(e)) => log::debug!(">>> {} (!! ERR: {} !!)", bridge.endpoint, e),
// None => log::debug!(">>> {} (!! TIMEOUT !!)", bridge.endpoint),
// }
// })
// })
// .collect::<Vec<_>>();
// for task in iter {
// task.await;
// }
// }
// Ok(())
}