mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 10:14:35 +00:00
magic dns (#813)
This patch implements: 1. A dns server that handles .et.net. zone in local and forward all other queries to system dns server. 2. A dns server instance which is a singleton in one machine, using one specific tcp port to be exclusive with each other. this instance is responsible for config system dns and run the dns server to handle dns queries. 3. A dns client instance that all easytier instance will run one, this instance will try to connect to dns server instance, and update the dns record in the dns server instance. this pr only implements the system config for windows. linux & mac will do later.
This commit is contained in:
@@ -1030,6 +1030,8 @@ struct PeerRouteServiceImpl {
|
||||
cached_local_conn_map: std::sync::Mutex<RouteConnBitmap>,
|
||||
|
||||
last_update_my_foreign_network: AtomicCell<Option<std::time::Instant>>,
|
||||
|
||||
peer_info_last_update: AtomicCell<std::time::Instant>,
|
||||
}
|
||||
|
||||
impl Debug for PeerRouteServiceImpl {
|
||||
@@ -1076,6 +1078,8 @@ impl PeerRouteServiceImpl {
|
||||
cached_local_conn_map: std::sync::Mutex::new(RouteConnBitmap::new()),
|
||||
|
||||
last_update_my_foreign_network: AtomicCell::new(None),
|
||||
|
||||
peer_info_last_update: AtomicCell::new(std::time::Instant::now()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1225,6 +1229,8 @@ impl PeerRouteServiceImpl {
|
||||
}
|
||||
|
||||
fn update_route_table_and_cached_local_conn_bitmap(&self) {
|
||||
self.update_peer_info_last_update();
|
||||
|
||||
// update route table first because we want to filter out unreachable peers.
|
||||
self.update_route_table();
|
||||
|
||||
@@ -1347,6 +1353,9 @@ impl PeerRouteServiceImpl {
|
||||
if my_conn_info_updated || my_peer_info_updated {
|
||||
self.update_foreign_network_owner_map();
|
||||
}
|
||||
if my_peer_info_updated {
|
||||
self.update_peer_info_last_update();
|
||||
}
|
||||
my_peer_info_updated || my_conn_info_updated || my_foreign_network_updated
|
||||
}
|
||||
|
||||
@@ -1547,6 +1556,15 @@ impl PeerRouteServiceImpl {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
fn update_peer_info_last_update(&self) {
|
||||
tracing::debug!(?self, "update_peer_info_last_update");
|
||||
self.peer_info_last_update.store(std::time::Instant::now());
|
||||
}
|
||||
|
||||
fn get_peer_info_last_update(&self) -> std::time::Instant {
|
||||
self.peer_info_last_update.load()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for PeerRouteServiceImpl {
|
||||
@@ -2195,6 +2213,10 @@ impl Route for PeerRoute {
|
||||
.get(&peer_id)
|
||||
.and_then(|x| x.feature_flag.clone())
|
||||
}
|
||||
|
||||
async fn get_peer_info_last_update_time(&self) -> Instant {
|
||||
self.service_impl.get_peer_info_last_update()
|
||||
}
|
||||
}
|
||||
|
||||
impl PeerPacketFilter for Arc<PeerRoute> {}
|
||||
|
||||
Reference in New Issue
Block a user