mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-02 09:09:17 +00:00
chore: move constants to mod.rs, format
This commit is contained in:
@@ -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<LowerName> =
|
|
||||||
LazyLock::new(|| LowerName::from_str("et.net.").unwrap());
|
|
||||||
pub static DNS_SERVER_RPC_ADDR: LazyLock<Url> =
|
|
||||||
LazyLock::new(|| Url::parse("tcp://127.0.0.1:49813").unwrap());
|
|
||||||
@@ -1,6 +1,29 @@
|
|||||||
mod constants;
|
use crate::dns::utils::NameServerAddr;
|
||||||
pub use constants::*;
|
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;
|
mod dns;
|
||||||
pub use dns::*;
|
pub use dns::*;
|
||||||
mod policy;
|
mod policy;
|
||||||
mod zone;
|
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<LowerName> =
|
||||||
|
LazyLock::new(|| LowerName::from_str("et.net.").unwrap());
|
||||||
|
pub static DNS_SERVER_RPC_ADDR: LazyLock<Url> =
|
||||||
|
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,
|
||||||
|
];
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ pub struct DnsServer {
|
|||||||
global_ctx: Arc<GlobalCtx>,
|
global_ctx: Arc<GlobalCtx>,
|
||||||
clients: Cache<Uuid, DnsClientInfo>,
|
clients: Cache<Uuid, DnsClientInfo>,
|
||||||
catalog: DynamicCatalog,
|
catalog: DynamicCatalog,
|
||||||
server_task: Arc<Mutex<Option<JoinHandle<()>>>>,
|
server: Arc<Mutex<Option<JoinHandle<()>>>>,
|
||||||
dirty: Arc<DnsServerDirtyState>,
|
dirty: Arc<DnsServerDirtyState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ impl DnsServer {
|
|||||||
.flatten()
|
.flatten()
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
|
||||||
let mut server = self.server_task.lock().await;
|
let mut server = self.server.lock().await;
|
||||||
if let Some(old) = server.take() {
|
if let Some(old) = server.take() {
|
||||||
old.abort()
|
old.abort()
|
||||||
}
|
}
|
||||||
@@ -289,7 +289,7 @@ impl DnsServerRpc for DnsServer {
|
|||||||
self.clients
|
self.clients
|
||||||
.get(&id)
|
.get(&id)
|
||||||
.await
|
.await
|
||||||
.is_none_or(|client| client.digest != input.digest)
|
.is_none_or(|info| info.digest != input.digest)
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(HeartbeatResponse { resync })
|
Ok(HeartbeatResponse { resync })
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::dns::config::DNS_SUPPORTED_PROTOCOLS;
|
||||||
use crate::proto;
|
use crate::proto;
|
||||||
use crate::proto::utils::RepeatedMessageModel;
|
use crate::proto::utils::RepeatedMessageModel;
|
||||||
use anyhow::{anyhow, Error};
|
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)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, SerializeDisplay, DeserializeFromStr)]
|
||||||
pub struct NameServerAddr {
|
pub struct NameServerAddr {
|
||||||
pub(super) protocol: Protocol,
|
pub(super) protocol: Protocol,
|
||||||
|
|||||||
Reference in New Issue
Block a user