parent
1ebb49da0a
commit
0a8a326730
@ -68,6 +68,7 @@ namespace net {
|
||||
string ip() const;
|
||||
string downspeed(int minwidth = 3) const;
|
||||
string upspeed(int minwidth = 3) const;
|
||||
void set_unknown_up(bool unknown = true);
|
||||
|
||||
protected:
|
||||
void check_tuntap();
|
||||
@ -78,6 +79,7 @@ namespace net {
|
||||
link_status m_status{};
|
||||
string m_interface;
|
||||
bool m_tuntap{false};
|
||||
bool m_unknown_up{false};
|
||||
};
|
||||
|
||||
// }}}
|
||||
|
@ -51,6 +51,7 @@ namespace modules {
|
||||
int m_ping_nth_update{0};
|
||||
int m_udspeed_minwidth{0};
|
||||
bool m_accumulate{false};
|
||||
bool m_unknown_up{false};
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -141,6 +141,13 @@ namespace net {
|
||||
return format_speedrate(bytes_diff, minwidth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if unknown counts as up
|
||||
*/
|
||||
void network::set_unknown_up(bool unknown) {
|
||||
m_unknown_up = unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query driver info to check if the
|
||||
* interface is a TUN/TAP device
|
||||
@ -174,7 +181,9 @@ namespace net {
|
||||
* Test if the network interface is in a valid state
|
||||
*/
|
||||
bool network::test_interface() const {
|
||||
return file_util::contents("/sys/class/net/" + m_interface + "/operstate").compare(0, 2, "up") == 0;
|
||||
auto operstate = file_util::contents("/sys/class/net/" + m_interface + "/operstate");
|
||||
bool up = operstate.compare(0, 2, "up") == 0;
|
||||
return m_unknown_up ? (up || operstate.compare(0, 7, "unknown") == 0) : up;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,7 @@ namespace modules {
|
||||
m_udspeed_minwidth = m_conf.get(name(), "udspeed-minwidth", m_udspeed_minwidth);
|
||||
m_accumulate = m_conf.get(name(), "accumulate-stats", m_accumulate);
|
||||
m_interval = m_conf.get<decltype(m_interval)>(name(), "interval", 1s);
|
||||
m_unknown_up = m_conf.get<bool>(name(), "unknown-as-up", false);
|
||||
|
||||
m_conf.warn_deprecated(name(), "udspeed-minwidth", "%downspeed:min:max% and %upspeed:min:max%");
|
||||
|
||||
@ -62,8 +63,10 @@ namespace modules {
|
||||
// Get an intstance of the network interface
|
||||
if (net::is_wireless_interface(m_interface)) {
|
||||
m_wireless = factory_util::unique<net::wireless_network>(m_interface);
|
||||
m_wireless->set_unknown_up(m_unknown_up);
|
||||
} else {
|
||||
m_wired = factory_util::unique<net::wired_network>(m_interface);
|
||||
m_wired->set_unknown_up(m_unknown_up);
|
||||
};
|
||||
|
||||
// We only need to start the subthread if the packetloss animation is used
|
||||
|
Loading…
Reference in New Issue
Block a user