fix: net: use an exception in NetworkAddress::resolve()

Instead of asserting that the number of resolved ipv4 addresses is nonzero,
throw an exception. This will prevent the core from aborting if the host has
no ipv4 addresses.

The host can get into this state if the remote device loses its ipv4
advertisement midway through resolving, such as if an mdns host unpublishes
its ipv4 address as a result of going into a low-power state.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross
2025-11-03 22:06:55 +08:00
committed by Chris Rizzitello
parent 9f669dbbce
commit dc0a85d34f

View File

@ -142,7 +142,9 @@ size_t NetworkAddress::resolve(size_t index)
}
resolvedAddressesCount = ipv4OnlyAddresses.size();
assert(resolvedAddressesCount > 0);
if (resolvedAddressesCount <= 0) {
throw ArchNetworkNameUnknownException("Hostname lookup failed");
}
if (index < resolvedAddressesCount - 1) {
m_address = ipv4OnlyAddresses[index];
} else {