diff --git a/src/adapters/net.cpp b/src/adapters/net.cpp index 0b79e123..40c8b89f 100644 --- a/src/adapters/net.cpp +++ b/src/adapters/net.cpp @@ -52,11 +52,6 @@ namespace net { * Query device driver for information */ bool network::query(bool accumulate) { - struct ifaddrs* ifaddr; - if (getifaddrs(&ifaddr) == -1 || ifaddr == nullptr) { - return false; - } - m_status.previous = m_status.current; m_status.current.transmitted = 0; m_status.current.received = 0; @@ -64,6 +59,11 @@ namespace net { m_status.ip = NO_IP; m_status.ip6 = NO_IP; + struct ifaddrs* ifaddr; + if (getifaddrs(&ifaddr) == -1 || ifaddr == nullptr) { + return false; + } + for (auto ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) { if (ifa->ifa_addr == nullptr) { continue; @@ -248,10 +248,12 @@ namespace net { * Query device driver for information */ bool wired_network::query(bool accumulate) { + if (!network::query(accumulate)) { + return false; + } + if (m_tuntap) { return true; - } else if (!network::query(accumulate)) { - return false; } if(m_bridge) {