store DnsServer in GlobalCtx, load routes from DnsServer in ProxyCidrsMonitor

This commit is contained in:
Luna Yao
2026-04-06 11:54:02 +02:00
parent 3fc030de48
commit 86871b14d5
5 changed files with 29 additions and 3 deletions
+14
View File
@@ -32,7 +32,9 @@ use crate::{
};
use crossbeam::atomic::AtomicCell;
use hmac::{Hmac, Mac};
use parking_lot::RwLock;
use sha2::Sha256;
use crate::dns::server::DnsServer;
use socket2::Protocol;
pub type NetworkIdentity = crate::common::config::NetworkIdentity;
@@ -202,6 +204,8 @@ pub struct GlobalCtx {
hostname: Mutex<String>,
dns: RwLock<Option<Arc<DnsServer>>>,
stun_info_collection: Mutex<Arc<dyn StunInfoCollectorTrait>>,
running_listeners: Mutex<Vec<url::Url>>,
@@ -298,6 +302,8 @@ impl GlobalCtx {
stun_info_collector.clone(),
)))),
dns: RwLock::new(None),
hostname: Mutex::new(hostname),
stun_info_collection: Mutex::new(stun_info_collector),
@@ -416,6 +422,14 @@ impl GlobalCtx {
self.ip_collector.lock().unwrap().as_ref().unwrap().clone()
}
pub fn get_dns(&self) -> Option<Arc<DnsServer>> {
self.dns.read().clone()
}
pub fn set_dns(&self, dns: Option<Arc<DnsServer>>) {
*self.dns.write() = dns;
}
pub fn get_hostname(&self) -> String {
return self.hostname.lock().unwrap().clone();
}