From 2865e3a23e25922aae584fa56b8adb55130e1e15 Mon Sep 17 00:00:00 2001 From: pradt2 Date: Wed, 17 Nov 2021 16:31:24 +0000 Subject: [PATCH] Added output shuffling --- src/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 065e7780d..4cabbee98 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,8 @@ use std::collections::HashSet; +use std::thread; use stunclient::Error; use tokio::{io}; +use tokio::macros::support::thread_rng_n; use tokio::time::Instant; use tokio_stream::{iter, StreamExt}; use crate::stun::CheckError; @@ -41,7 +43,7 @@ async fn main() -> io::Result<()> { .filter_map(|res| res.as_ref().ok()) .map(|profile| profile.candidate.clone()) .collect::>(); - output.sort(); + output.shuffle(thread::thread_rng()); let output_hosts = output.into_iter() .map(|candidate| String::from(candidate)) .reduce(|a, b| format!("{}\n{}", a, b)) @@ -56,7 +58,7 @@ async fn main() -> io::Result<()> { .collect::>(); let mut output_ip4 = output_ip4.into_iter() .collect::>(); - output_ip4.sort(); + output_ip4.shuffle(thread::thread_rng()); let output_ip4 = output_ip4.into_iter() .reduce(|a, b| format!("{}\n{}", a, b)) .unwrap_or(String::from("")); @@ -70,7 +72,7 @@ async fn main() -> io::Result<()> { .collect::>(); let mut output_ip6 = output_ip6.into_iter() .collect::>(); - output_ip6.sort(); + output_ip6.shuffle(thread::thread_rng()); let output_ip6 = output_ip6.into_iter() .reduce(|a, b| format!("{}\n{}", a, b)) .unwrap_or(String::from(""));