mirror of
https://github.com/YGGverse/yps.git
synced 2026-03-31 17:05:30 +00:00
use HashSet for keys index
This commit is contained in:
parent
42f80177ea
commit
4d1455d34e
1 changed files with 5 additions and 5 deletions
10
src/main.rs
10
src/main.rs
|
|
@ -6,7 +6,7 @@ use anyhow::Result;
|
|||
use colored::*;
|
||||
use config::Config;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
collections::{HashMap, HashSet},
|
||||
net::{IpAddr, SocketAddr, TcpStream},
|
||||
time::Duration,
|
||||
};
|
||||
|
|
@ -23,7 +23,7 @@ fn main() -> Result<()> {
|
|||
panic!("at least one TCP or UDP protocol is required for scan!")
|
||||
}
|
||||
let mut ygg = Yggdrasil::init(&config.socket)?;
|
||||
let mut key: Vec<String> = Vec::with_capacity(config.index_capacity);
|
||||
let mut key: HashSet<String> = HashSet::with_capacity(config.index_capacity);
|
||||
let mut tcp = if config.tcp {
|
||||
Some(HashMap::with_capacity(config.index_capacity))
|
||||
} else {
|
||||
|
|
@ -70,7 +70,7 @@ fn crawl(
|
|||
k: String,
|
||||
config: &Config,
|
||||
ygg: &mut Yggdrasil,
|
||||
key: &mut Vec<String>,
|
||||
key: &mut HashSet<String>,
|
||||
tcp: &mut Option<HashMap<SocketAddr, bool>>,
|
||||
udp: &mut Option<(HashMap<SocketAddr, bool>, Udp)>,
|
||||
) -> Result<()> {
|
||||
|
|
@ -82,7 +82,7 @@ fn crawl(
|
|||
}
|
||||
let p = ygg.remote_peers(&k)?;
|
||||
if p.status == "success" {
|
||||
key.push(k);
|
||||
assert!(key.insert(k));
|
||||
if let Some(response) = p.response {
|
||||
for (host, peers) in response {
|
||||
for port in &config.port {
|
||||
|
|
@ -127,7 +127,7 @@ fn crawl(
|
|||
WARNING.yellow(),
|
||||
p.status
|
||||
);
|
||||
key.push(k) // ban
|
||||
assert!(key.insert(k)) // ban
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue