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:
Sijie.Sun
2025-05-16 09:24:24 +08:00
committed by GitHub
parent 99430983bc
commit 28fe6257be
40 changed files with 2800 additions and 229 deletions
+22
View File
@@ -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> {}