Warn about a zone name only when it collides with something

"`.pidar` is not a delegated top-level domain today, but it could become
one" fired on every private name anybody has ever picked, which is every
network without a dot in its name. A warning that is always there is a
warning about nothing, and it teaches people to skim past the ones that
mean something — there were two of them in one report, side by side with
the real checks.

What is left is the collision that exists: a name that really is a public
top-level domain, which does make every public name under it unreachable
from that host, and `.local`, which belongs to multicast DNS. A name that
shadows nothing is said nothing about.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
tsunagi
2026-09-22 02:09:17 +01:00
co-authored by Claude Opus 5
parent 83d3445b7e
commit 458051f47d
2 changed files with 19 additions and 19 deletions
+13 -14
View File
@@ -128,17 +128,14 @@ impl ZoneName {
.to_string(),
);
}
if tld::exist_case_insensitive(top) {
return Some(format!(
// A real top-level domain is the whole of it. A name that is not
// delegated today might be one day — and saying so fires on every
// private name anybody ever picks, which is a warning about
// nothing that teaches people to ignore warnings.
tld::exist_case_insensitive(top).then(|| {
format!(
"`.{top}` is a real top-level domain, so every public name under it \
becomes unreachable from this host while the overlay is up"
));
}
// Not delegated today is not a promise about tomorrow.
(!self.0.contains('.')).then(|| {
format!(
"`.{top}` is not a delegated top-level domain today, but it could \
become one; `.internal` is reserved for private use and never will"
)
})
}
@@ -516,11 +513,13 @@ mod tests {
let local = ZoneName::new("local").unwrap().collision().unwrap();
assert!(local.contains("multicast DNS"), "{local}");
// An undelegated single label is a maybe, not a yes.
let lab = ZoneName::new("lab").unwrap().collision().unwrap();
assert!(lab.contains("could"), "{lab}");
// A multi-label name under something undelegated is not worth a word.
assert_eq!(ZoneName::new("a.lab").unwrap().collision(), None);
// A name that collides with nothing is said nothing about. It
// might be delegated one day, and warning about that fires on
// every private name anybody picks — a warning about nothing,
// which is how people learn to ignore warnings.
for quiet in ["lab", "a.lab", "pidar", "twar", "kitchen-table"] {
assert_eq!(ZoneName::new(quiet).unwrap().collision(), None, "{quiet}");
}
}
#[test]