mirror of
https://git.alemi.dev/fedicharter.git
synced 2024-11-22 16:34:49 +01:00
feat: kinda botchy way to exclude subdomains
This commit is contained in:
parent
92b2075c9d
commit
e1e80a717d
1 changed files with 10 additions and 6 deletions
16
src/model.rs
16
src/model.rs
|
@ -11,7 +11,7 @@ pub struct MapCollector {
|
|||
pub fn create_map_collector() -> (MapCollector, MapHandle) {
|
||||
let (nodes_tx, nodes_rx) = mpsc::unbounded_channel();
|
||||
let (vertices_tx, vertices_rx) = mpsc::unbounded_channel();
|
||||
let scanned = Arc::new(RwLock::new(HashSet::new()));
|
||||
let scanned = Arc::new(RwLock::new(Vec::new()));
|
||||
(
|
||||
MapCollector { nodes_rx, vertices_rx },
|
||||
MapHandle { nodes_tx, vertices_tx, scanned },
|
||||
|
@ -55,7 +55,7 @@ impl MapCollector {
|
|||
|
||||
let to = {
|
||||
if let Some(node) = nodes_map.get_mut(&vertex.to) {
|
||||
node.value += 5;
|
||||
node.value += 10;
|
||||
node.id
|
||||
} else {
|
||||
tracing::warn!("vertex to nonexisting node {}", vertex.to);
|
||||
|
@ -76,16 +76,20 @@ impl MapCollector {
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct MapHandle {
|
||||
scanned: Arc<RwLock<HashSet<String>>>,
|
||||
scanned: Arc<RwLock<Vec<String>>>,
|
||||
nodes_tx: mpsc::UnboundedSender<NodeDomain>,
|
||||
vertices_tx: mpsc::UnboundedSender<VertexDomain>,
|
||||
}
|
||||
|
||||
impl MapHandle {
|
||||
pub async fn already_scanned(&self, domain: &str) -> bool {
|
||||
let present = self.scanned.read().await.contains(domain);
|
||||
if !present { self.scanned.write().await.insert(domain.to_string()); }
|
||||
present
|
||||
for scanned_domain in self.scanned.read().await.iter() {
|
||||
if scanned_domain.ends_with(domain) || domain.ends_with(scanned_domain) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
self.scanned.write().await.push(domain.to_string());
|
||||
false
|
||||
}
|
||||
|
||||
pub fn add_node(&self, domain: String, name: String) {
|
||||
|
|
Loading…
Reference in a new issue