fix(domain): shape check sees positional parents, multicast never an own address

This commit is contained in:
bchanot committed 2026-10-24 03:47:07 +02:00
1 parent 257a29b09b
commit 1ec9e1bea6
6 files changed
+273 -8

No files matched your search

@@ -115,6 +115,10 @@ fn own_address(host: &str) -> bool {
let Ok(ip) = host.parse::<std::net::IpAddr>() else {
return false;
};
// A multicast group binds and connects like an own address on Linux: never unicast.
if ip.is_multicast() {
return false;
}
let Ok(socket) = std::net::UdpSocket::bind((ip, 0)) else {
return false;
};
@@ -254,7 +258,14 @@ mod tests {
#[test]
fn only_an_own_unicast_address_counts_as_the_dev_address() {
assert!(own_address("127.0.0.1"));
for refused in ["255.255.255.255", "203.0.113.7", "not-an-ip", ""] {
for refused in [
"255.255.255.255",
"224.0.0.1",
"239.255.255.250",
"203.0.113.7",
"not-an-ip",
"",
] {
assert!(!own_address(refused), "{refused}");
}
let (unicast, broadcast) = host_addresses();