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 colored::*;
|
||||||
use config::Config;
|
use config::Config;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::{HashMap, HashSet},
|
||||||
net::{IpAddr, SocketAddr, TcpStream},
|
net::{IpAddr, SocketAddr, TcpStream},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
@ -23,7 +23,7 @@ fn main() -> Result<()> {
|
||||||
panic!("at least one TCP or UDP protocol is required for scan!")
|
panic!("at least one TCP or UDP protocol is required for scan!")
|
||||||
}
|
}
|
||||||
let mut ygg = Yggdrasil::init(&config.socket)?;
|
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 {
|
let mut tcp = if config.tcp {
|
||||||
Some(HashMap::with_capacity(config.index_capacity))
|
Some(HashMap::with_capacity(config.index_capacity))
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -70,7 +70,7 @@ fn crawl(
|
||||||
k: String,
|
k: String,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
ygg: &mut Yggdrasil,
|
ygg: &mut Yggdrasil,
|
||||||
key: &mut Vec<String>,
|
key: &mut HashSet<String>,
|
||||||
tcp: &mut Option<HashMap<SocketAddr, bool>>,
|
tcp: &mut Option<HashMap<SocketAddr, bool>>,
|
||||||
udp: &mut Option<(HashMap<SocketAddr, bool>, Udp)>,
|
udp: &mut Option<(HashMap<SocketAddr, bool>, Udp)>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
|
@ -82,7 +82,7 @@ fn crawl(
|
||||||
}
|
}
|
||||||
let p = ygg.remote_peers(&k)?;
|
let p = ygg.remote_peers(&k)?;
|
||||||
if p.status == "success" {
|
if p.status == "success" {
|
||||||
key.push(k);
|
assert!(key.insert(k));
|
||||||
if let Some(response) = p.response {
|
if let Some(response) = p.response {
|
||||||
for (host, peers) in response {
|
for (host, peers) in response {
|
||||||
for port in &config.port {
|
for port in &config.port {
|
||||||
|
|
@ -127,7 +127,7 @@ fn crawl(
|
||||||
WARNING.yellow(),
|
WARNING.yellow(),
|
||||||
p.status
|
p.status
|
||||||
);
|
);
|
||||||
key.push(k) // ban
|
assert!(key.insert(k)) // ban
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue