mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 10:14:35 +00:00
Add is_hole_punched flag to PeerConn (#1001)
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user