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