This commit is contained in:
AlexandreRouma 2023-03-08 19:39:15 +01:00
parent 4283cacae6
commit 9cc793e328
2 changed files with 2 additions and 0 deletions

View File

@ -289,6 +289,7 @@ namespace net {
// Save data // Save data
for (auto iface = addresses; iface; iface = iface->ifa_next) { for (auto iface = addresses; iface; iface = iface->ifa_next) {
if (iface->ifa_addr->sa_family != AF_INET) { continue; } if (iface->ifa_addr->sa_family != AF_INET) { continue; }
if (!iface->ifa_addr || !iface->ifa_netmask) { continue; }
InterfaceInfo info; InterfaceInfo info;
info.address = ntohl(*(uint32_t*)&iface->ifa_addr->sa_data[2]); info.address = ntohl(*(uint32_t*)&iface->ifa_addr->sa_data[2]);
info.netmask = ntohl(*(uint32_t*)&iface->ifa_netmask->sa_data[2]); info.netmask = ntohl(*(uint32_t*)&iface->ifa_netmask->sa_data[2]);

View File

@ -205,6 +205,7 @@ namespace hermes {
} }
std::vector<Info> discover() { std::vector<Info> discover() {
// TODO: Maybe try to instead detect on each interface as a work around for 0.0.0.0 not receiving anything?
auto sock = net::openudp("0.0.0.0", 1024); auto sock = net::openudp("0.0.0.0", 1024);
// Build discovery packet // Build discovery packet