From fc23f19ad8c07f8c475b4652568fb09cec0a4456 Mon Sep 17 00:00:00 2001 From: pradt2 Date: Wed, 17 Nov 2021 17:20:08 +0000 Subject: [PATCH] Fix missing imports --- Cargo.lock | 1 + Cargo.toml | 1 + src/main.rs | 10 ++++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 74dac0621..fbe2e811d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,6 +7,7 @@ name = "always-online-stun" version = "0.1.0" dependencies = [ "futures", + "rand", "stunclient", "tokio", "tokio-stream", diff --git a/Cargo.toml b/Cargo.toml index 9f5f4d9bb..17997811d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 4cabbee98..3dacf8eba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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::>(); - 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::>(); let mut output_ip4 = output_ip4.into_iter() .collect::>(); - 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::>(); let mut output_ip6 = output_ip6.into_iter() .collect::>(); - 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(""));