Fix missing imports

This commit is contained in:
pradt2 2021-11-17 17:20:08 +00:00
parent e023fa81b9
commit fc23f19ad8
3 changed files with 8 additions and 4 deletions

1
Cargo.lock generated
View File

@ -7,6 +7,7 @@ name = "always-online-stun"
version = "0.1.0"
dependencies = [
"futures",
"rand",
"stunclient",
"tokio",
"tokio-stream",

View File

@ -7,6 +7,7 @@ edition = "2018"
[dependencies]
futures = { version = "0.3.17" }
rand = { version = "0.8.4", default-features = false }
stunclient = { version = "0.3.1", default-features = false, features = ["async"] }
tokio = { version = "1.14.0", default-features = false, features = ["fs", "macros", "net", "rt"] }
tokio-stream = { version = "0.1.8", default-features = false }

View File

@ -1,5 +1,7 @@
use std::collections::HashSet;
use std::thread;
use rand::seq::SliceRandom;
use rand::thread_rng;
use stunclient::Error;
use tokio::{io};
use tokio::macros::support::thread_rng_n;
@ -31,7 +33,7 @@ async fn main() -> io::Result<()> {
let mut complete_timeout = 0;
results.iter().for_each(|res| {
match res {
Ok(profile) => { all_ok += 1; }
Ok(_) => { all_ok += 1; }
Err(CheckError::DnsResolutionFailed) => { dns_unresolved += 1; }
Err(CheckError::PartialTimeout) => { partial_timeout += 1; }
Err(CheckError::Timeout) => { complete_timeout += 1; }
@ -43,7 +45,7 @@ async fn main() -> io::Result<()> {
.filter_map(|res| res.as_ref().ok())
.map(|profile| profile.candidate.clone())
.collect::<Vec<_>>();
output.shuffle(thread::thread_rng());
output.shuffle(&mut thread_rng());
let output_hosts = output.into_iter()
.map(|candidate| String::from(candidate))
.reduce(|a, b| format!("{}\n{}", a, b))
@ -58,7 +60,7 @@ async fn main() -> io::Result<()> {
.collect::<HashSet<_>>();
let mut output_ip4 = output_ip4.into_iter()
.collect::<Vec<_>>();
output_ip4.shuffle(thread::thread_rng());
output_ip4.shuffle(&mut thread_rng());
let output_ip4 = output_ip4.into_iter()
.reduce(|a, b| format!("{}\n{}", a, b))
.unwrap_or(String::from(""));
@ -72,7 +74,7 @@ async fn main() -> io::Result<()> {
.collect::<HashSet<_>>();
let mut output_ip6 = output_ip6.into_iter()
.collect::<Vec<_>>();
output_ip6.shuffle(thread::thread_rng());
output_ip6.shuffle(&mut thread_rng());
let output_ip6 = output_ip6.into_iter()
.reduce(|a, b| format!("{}\n{}", a, b))
.unwrap_or(String::from(""));