fix(net): Query IP addresses for tun/ tap devices

Before tuntap devices would never call the generic `network::query`
method and just return true.

Fixes #1986
This commit is contained in:
patrick96 2020-01-12 14:00:32 +01:00 committed by Patrick Ziegler
parent e43ba9bd3a
commit 0dbcb28a2c

View File

@ -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) {