mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
best address logic
This commit is contained in:
@@ -194,7 +194,12 @@ pub async fn add_domain<Kind: HostApiKind>(
|
||||
.as_domains()
|
||||
.keys()?
|
||||
.into_iter()
|
||||
.find(|root| domain.ends_with(&**root))
|
||||
.find(|root| {
|
||||
domain == root
|
||||
|| domain
|
||||
.strip_suffix(&**root)
|
||||
.map_or(false, |d| d.ends_with("."))
|
||||
})
|
||||
.or_not_found(lazy_format!("root domain for {domain}"))?;
|
||||
|
||||
if let Some(acme) = &acme {
|
||||
@@ -209,7 +214,6 @@ pub async fn add_domain<Kind: HostApiKind>(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Kind::host_for(&inheritance, db)?.as_domains_mut().insert(
|
||||
domain,
|
||||
&DomainConfig {
|
||||
|
||||
@@ -385,8 +385,7 @@ impl NetServiceData {
|
||||
gateway_id: interface.clone(),
|
||||
public, // TODO: check if port forward is active
|
||||
hostname: IpHostname::Domain {
|
||||
domain: address.clone(),
|
||||
subdomain: None,
|
||||
value: address.clone(),
|
||||
port: None,
|
||||
ssl_port: Some(443),
|
||||
},
|
||||
@@ -396,8 +395,7 @@ impl NetServiceData {
|
||||
gateway_id: interface.clone(),
|
||||
public,
|
||||
hostname: IpHostname::Domain {
|
||||
domain: address.clone(),
|
||||
subdomain: None,
|
||||
value: address.clone(),
|
||||
port: bind.net.assigned_port,
|
||||
ssl_port: bind.net.assigned_ssl_port,
|
||||
},
|
||||
|
||||
@@ -72,9 +72,7 @@ pub enum IpHostname {
|
||||
},
|
||||
Domain {
|
||||
#[ts(type = "string")]
|
||||
domain: InternedString,
|
||||
#[ts(type = "string | null")]
|
||||
subdomain: Option<InternedString>,
|
||||
value: InternedString,
|
||||
port: Option<u16>,
|
||||
ssl_port: Option<u16>,
|
||||
},
|
||||
@@ -85,15 +83,7 @@ impl IpHostname {
|
||||
Self::Ipv4 { value, .. } => InternedString::from_display(value),
|
||||
Self::Ipv6 { value, .. } => InternedString::from_display(value),
|
||||
Self::Local { value, .. } => value.clone(),
|
||||
Self::Domain {
|
||||
domain, subdomain, ..
|
||||
} => {
|
||||
if let Some(subdomain) = subdomain {
|
||||
InternedString::from_display(&lazy_format!("{subdomain}.{domain}"))
|
||||
} else {
|
||||
domain.clone()
|
||||
}
|
||||
}
|
||||
Self::Domain { value, .. } => value.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user