fix magic-dns feature gate

This commit is contained in:
Luna Yao committed 2026-04-06 11:54:50 +02:00
1 parent d94cb3a96d
commit 385ff54b3e
13 files changed
+156 -117

No files matched your search

+1 -2
View File
@@ -25,6 +25,7 @@ use crate::connector::direct::DirectConnectorManager;
use crate::connector::manual::{ConnectorManagerRpcService, ManualConnectorManager};
use crate::connector::tcp_hole_punch::TcpHolePunchConnector;
use crate::connector::udp_hole_punch::UdpHolePunchConnector;
#[cfg(feature = "magic-dns")]
use crate::dns::node::DnsNode;
use crate::gateway::icmp_proxy::IcmpProxy;
#[cfg(feature = "kcp")]
@@ -1383,8 +1384,6 @@ impl Instance {
.await
.with_context(|| "add ip failed")?;
self.dns.start();
Self::use_new_nic_ctx(nic_ctx.clone(), new_nic_ctx).await;
Ok(())
}
+9 -6
View File
@@ -1,7 +1,6 @@
use std::collections::BTreeSet;
use std::net::IpAddr;
use std::sync::{Arc, Weak};
use std::time::Instant;
use crate::common::global_ctx::{ArcGlobalCtx, GlobalCtxEvent};
use crate::common::scoped_task::ScopedTask;
@@ -55,11 +54,15 @@ impl ProxyCidrsMonitor {
proxy_cidrs = routes.into_iter().collect();
}
if let Some(dns) = global_ctx.get_dns() {
proxy_cidrs.extend(dns.addresses().into_iter().filter_map(|a| match a.ip() {
IpAddr::V4(ip) => Some(cidr::Ipv4Cidr::new_host(ip)),
_ => None,
}))
#[cfg(feature = "magic-dns")]
{
use crate::dns::config::DnsGlobalCtxExt;
if let Some(dns) = global_ctx.dns_server() {
proxy_cidrs.extend(dns.addresses().into_iter().filter_map(|a| match a.ip() {
IpAddr::V4(ip) => Some(cidr::Ipv4Cidr::new_host(ip)),
_ => None,
}))
}
}
// Calculate diff