store DnsServer in GlobalCtx, load routes from DnsServer in ProxyCidrsMonitor

This commit is contained in:
Luna Yao committed 2026-04-06 11:54:02 +02:00
1 parent 3fc030de48
commit 86871b14d5
5 files changed
+29 -3

No files matched your search

@@ -1,4 +1,5 @@
use std::collections::BTreeSet;
use std::net::IpAddr;
use std::sync::{Arc, Weak};
use std::time::Instant;
@@ -54,6 +55,13 @@ 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,
}))
}
// Calculate diff
if cur_proxy_cidrs == &proxy_cidrs {
return (proxy_cidrs, Vec::new(), Vec::new());