mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-08-06 12:39:51 +00:00
config: set name to optional
This commit is contained in:
@@ -20,8 +20,6 @@ use super::{
|
||||
network::IPCollector,
|
||||
stun::{StunInfoCollector, StunInfoCollectorTrait},
|
||||
};
|
||||
#[cfg(feature = "magic-dns")]
|
||||
use crate::dns::config::{DnsConfigLoaderExt, DnsExportConfig, DnsGlobalCtxExt, zone::ZoneConfig};
|
||||
use crate::{
|
||||
common::{
|
||||
config::ProxyNetworkConfig, shrink_dashmap, stats_manager::StatsManager,
|
||||
@@ -37,6 +35,11 @@ use crate::{
|
||||
rpc_service::protected_port,
|
||||
tunnel::matches_protocol,
|
||||
};
|
||||
#[cfg(feature = "magic-dns")]
|
||||
use crate::{
|
||||
dns::config::{DnsConfigLoaderExt, DnsExportConfig, DnsGlobalCtxExt, zone::ZoneConfig},
|
||||
utils::dns,
|
||||
};
|
||||
|
||||
pub type NetworkIdentity = crate::common::config::NetworkIdentity;
|
||||
|
||||
@@ -725,16 +728,14 @@ impl GlobalCtx {
|
||||
#[cfg(feature = "magic-dns")]
|
||||
impl DnsGlobalCtxExt for GlobalCtx {
|
||||
fn dns_self_zone(&self) -> ZoneConfig {
|
||||
use hickory_proto::rr::Name;
|
||||
let dns = self.config.get_dns();
|
||||
let mut hostname = dns.name.to_string();
|
||||
if hostname.is_empty() {
|
||||
hostname = self.get_hostname();
|
||||
}
|
||||
let fqdn = dns
|
||||
.domain
|
||||
.prepend_label(hostname)
|
||||
.unwrap_or_default()
|
||||
let name: Name = dns
|
||||
.name
|
||||
.clone()
|
||||
.unwrap_or_else(|| dns::parse(self.get_hostname()))
|
||||
.into();
|
||||
let fqdn = name.append_domain(&*dns.domain).unwrap_or_default().into();
|
||||
let ipv4 = self.get_ipv4().map(|ip| ip.address());
|
||||
let ipv6 = self.get_ipv6().map(|ip| ip.address());
|
||||
let ipv6 = ipv6.map(|a| vec![a]).unwrap_or_default();
|
||||
|
||||
@@ -18,7 +18,7 @@ pub struct DnsConfigParsed {
|
||||
#[optional_skip_wrap]
|
||||
#[serde(flatten)]
|
||||
pub policies: HashMap<LowerName, DnsPolicyConfig>,
|
||||
pub name: LowerName,
|
||||
pub name: Option<LowerName>,
|
||||
pub domain: LowerName,
|
||||
pub addresses: NameServerAddrGroup,
|
||||
pub listeners: NameServerAddrGroup,
|
||||
@@ -30,7 +30,6 @@ impl From<DnsConfigRaw> for DnsConfig {
|
||||
fn from(raw: DnsConfigRaw) -> Self {
|
||||
let default = DnsConfigParsed {
|
||||
domain: DNS_DEFAULT_DOMAIN.clone(),
|
||||
name: DNS_DEFAULT_DOMAIN.clone(),
|
||||
addresses: DNS_DEFAULT_ADDRESSES.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user