From a5fdebe778284388430038c087e2738b536b49cf Mon Sep 17 00:00:00 2001 From: Luna Yao <40349250+ZnqbuZ@users.noreply.github.com> Date: Sat, 21 Feb 2026 01:15:10 +0100 Subject: [PATCH] chore: move constants to mod.rs, format --- easytier/src/dns/config/constants.rs | 16 ---------------- easytier/src/dns/config/mod.rs | 27 +++++++++++++++++++++++++-- easytier/src/dns/server.rs | 6 +++--- easytier/src/dns/utils.rs | 10 +--------- 4 files changed, 29 insertions(+), 30 deletions(-) delete mode 100644 easytier/src/dns/config/constants.rs diff --git a/easytier/src/dns/config/constants.rs b/easytier/src/dns/config/constants.rs deleted file mode 100644 index fc311a93..00000000 --- a/easytier/src/dns/config/constants.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::dns::utils::NameServerAddr; -use hickory_proto::rr::LowerName; -use hickory_proto::xfer::Protocol; -use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4}; -use std::str::FromStr; -use std::sync::LazyLock; -use url::Url; - -pub const DNS_DEFAULT_ADDRESS: NameServerAddr = NameServerAddr { - protocol: Protocol::Udp, - addr: SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(100, 100, 100, 101), 53)), -}; -pub static DNS_DEFAULT_TLD: LazyLock = - LazyLock::new(|| LowerName::from_str("et.net.").unwrap()); -pub static DNS_SERVER_RPC_ADDR: LazyLock = - LazyLock::new(|| Url::parse("tcp://127.0.0.1:49813").unwrap()); diff --git a/easytier/src/dns/config/mod.rs b/easytier/src/dns/config/mod.rs index 9e480b77..b2e68789 100644 --- a/easytier/src/dns/config/mod.rs +++ b/easytier/src/dns/config/mod.rs @@ -1,6 +1,29 @@ -mod constants; -pub use constants::*; +use crate::dns::utils::NameServerAddr; +use hickory_proto::rr::LowerName; +use hickory_proto::xfer::Protocol; +use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4}; +use std::str::FromStr; +use std::sync::LazyLock; +use url::Url; + mod dns; pub use dns::*; mod policy; mod zone; + +pub const DNS_DEFAULT_ADDRESS: NameServerAddr = NameServerAddr { + protocol: Protocol::Udp, + addr: SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(100, 100, 100, 101), 53)), +}; +pub static DNS_DEFAULT_TLD: LazyLock = + LazyLock::new(|| LowerName::from_str("et.net.").unwrap()); +pub static DNS_SERVER_RPC_ADDR: LazyLock = + LazyLock::new(|| Url::parse("tcp://127.0.0.1:49813").unwrap()); +pub(super) static DNS_SUPPORTED_PROTOCOLS: [Protocol; 2] = [ + Protocol::Udp, + Protocol::Tcp, + // Protocol::Tls, + // Protocol::Https, + // Protocol::Quic, + // Protocol::H3, +]; diff --git a/easytier/src/dns/server.rs b/easytier/src/dns/server.rs index 7b61167e..c711d3da 100644 --- a/easytier/src/dns/server.rs +++ b/easytier/src/dns/server.rs @@ -98,7 +98,7 @@ pub struct DnsServer { global_ctx: Arc, clients: Cache, catalog: DynamicCatalog, - server_task: Arc>>>, + server: Arc>>>, dirty: Arc, } @@ -151,7 +151,7 @@ impl DnsServer { .flatten() .collect_vec(); - let mut server = self.server_task.lock().await; + let mut server = self.server.lock().await; if let Some(old) = server.take() { old.abort() } @@ -289,7 +289,7 @@ impl DnsServerRpc for DnsServer { self.clients .get(&id) .await - .is_none_or(|client| client.digest != input.digest) + .is_none_or(|info| info.digest != input.digest) }; Ok(HeartbeatResponse { resync }) diff --git a/easytier/src/dns/utils.rs b/easytier/src/dns/utils.rs index 62c01e3e..77e570a4 100644 --- a/easytier/src/dns/utils.rs +++ b/easytier/src/dns/utils.rs @@ -1,3 +1,4 @@ +use crate::dns::config::DNS_SUPPORTED_PROTOCOLS; use crate::proto; use crate::proto::utils::RepeatedMessageModel; use anyhow::{anyhow, Error}; @@ -54,15 +55,6 @@ pub fn parse(name: &str) -> LowerName { } } -static DNS_SUPPORTED_PROTOCOLS: [Protocol; 2] = [ - Protocol::Udp, - Protocol::Tcp, - // Protocol::Tls, - // Protocol::Https, - // Protocol::Quic, - // Protocol::H3, -]; - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, SerializeDisplay, DeserializeFromStr)] pub struct NameServerAddr { pub(super) protocol: Protocol,