mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-02 09:09:17 +00:00
store DnsServer in GlobalCtx, load routes from DnsServer in ProxyCidrsMonitor
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user