Add is_hole_punched flag to PeerConn (#1001)

This commit is contained in:
liusen373
2025-06-18 12:14:57 +08:00
committed by GitHub
parent 327ccdcf38
commit 72673a9d52
8 changed files with 47 additions and 92 deletions
+12 -1
View File
@@ -1,7 +1,7 @@
use std::sync::Arc;
use crossbeam::atomic::AtomicCell;
use dashmap::DashMap;
use dashmap::{DashMap, DashSet};
use tokio::{select, sync::mpsc};
@@ -200,6 +200,17 @@ impl Peer {
ret
}
pub fn has_directly_connected_conn(&self) -> bool {
self.conns.iter().any(|entry|!(entry.value()).is_hole_punched())
}
pub fn get_directly_connections(&self) -> DashSet<uuid::Uuid> {
self.conns.iter()
.filter(|entry| !(entry.value()).is_hole_punched())
.map(|entry|(entry.value()).get_conn_id())
.collect()
}
pub fn get_default_conn_id(&self) -> PeerConnId {
self.default_conn_id.load()
}