Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ See [STATUS.md](server/STATUS.md) to learn more about which features will remain

## UNRELEASED

- `--served-domain-suffix` / `ATOMIC_SERVED_DOMAIN_SUFFIX` takes a comma-separated list (`atomicserver.eu,atomic.place`), so a node can answer under two domains while it moves from one to the other.
- Forms (beta): guests can fill in a form without an account, and each answer
becomes a row in a Table. New default ontology `forms`
(`lib/defaults/forms.json`: `Form`, `FormPage`, `FormField`, `FormHeading`,
Expand Down
4 changes: 4 additions & 0 deletions server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ pub struct Opts {
/// This is what a managed node is given for hosted vanity subdomains; the
/// mapping from such a hostname to a Drive is separate, and lives in
/// `Tree::DriveMapping`.
///
/// Takes a comma-separated list (`atomicserver.eu,atomic.place`), for a
/// node that answers under two domains while it moves from one to the
/// other.
#[clap(long, env = "ATOMIC_SERVED_DOMAIN_SUFFIX")]
pub served_domain_suffix: Option<String>,

Expand Down
32 changes: 25 additions & 7 deletions server/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,15 @@ pub(crate) fn host_is_served_here(host: &str, opts: &crate::config::Opts) -> boo
{
return true;
}
for suffix in [
opts.base_domain.as_deref(),
opts.served_domain_suffix.as_deref(),
]
.into_iter()
.flatten()
{
// `--served-domain-suffix` takes a comma-separated list: a node that is
// moving from one domain to another answers for both while links to the
// old one are still around.
for suffix in opts.base_domain.as_deref().into_iter().chain(
opts.served_domain_suffix
.as_deref()
.unwrap_or("")
.split(','),
) {
let suffix = suffix.trim().trim_start_matches('.').to_ascii_lowercase();
if !suffix.is_empty() && (hostname == suffix || hostname.ends_with(&format!(".{suffix}"))) {
return true;
Expand Down Expand Up @@ -166,6 +168,22 @@ mod tests {
assert!(!host_is_served_here("evil.example", &o));
}

/// A node moving between domains is given both, comma separated, and
/// answers for names under either.
#[test]
fn several_served_domain_suffixes_are_all_served() {
let o = opts_with_served_suffix("node1.atomicserver.eu", "atomicserver.eu, atomic.place");

assert!(host_is_served_here("node1.atomicserver.eu", &o));
assert!(host_is_served_here("acme.atomicserver.eu", &o));
assert!(host_is_served_here("node1.atomic.place", &o));
assert!(host_is_served_here("NODE1.Atomic.Place:443", &o));

assert!(!host_is_served_here("notatomic.place", &o));
assert!(!host_is_served_here("atomic.place.evil.example", &o));
assert!(!host_is_served_here("evil.example", &o));
}

#[test]
fn configured_domain_and_tenants_are_served_here() {
let o = opts("atomicdata.dev", Some("atomicserver.eu"));
Expand Down
Loading