Skip to content

Commit

Permalink
Merge pull request #2140 from 257/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexays committed Apr 26, 2023
2 parents 757f20f + 3da3732 commit e4faf25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/modules/network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Network : public ALabel {
bool want_link_dump_;
bool want_addr_dump_;
bool dump_in_progress_;
bool is_p2p_;

unsigned long long bandwidth_down_total_;
unsigned long long bandwidth_up_total_;
Expand Down
11 changes: 9 additions & 2 deletions src/modules/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ waybar::modules::Network::Network(const std::string &id, const Json::Value &conf
want_link_dump_(false),
want_addr_dump_(false),
dump_in_progress_(false),
is_p2p_(false),
cidr_(0),
signal_strength_dbm_(0),
signal_strength_(0),
Expand Down Expand Up @@ -456,6 +457,8 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) {
case IFLA_IFNAME:
ifname = static_cast<const char *>(RTA_DATA(ifla));
ifname_len = RTA_PAYLOAD(ifla) - 1; // minus \0
if (ifi->ifi_flags & IFF_POINTOPOINT && net->checkInterface(ifname))
net->is_p2p_ = true;
break;
case IFLA_CARRIER: {
carrier = *(char *)RTA_DATA(ifla) == 1;
Expand Down Expand Up @@ -494,6 +497,8 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) {

net->ifname_ = new_ifname;
net->ifid_ = ifi->ifi_index;
if (ifi->ifi_flags & IFF_POINTOPOINT)
net->is_p2p_ = true;
if (carrier.has_value()) {
net->carrier_ = carrier.value();
}
Expand Down Expand Up @@ -537,7 +542,10 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) {

for (; RTA_OK(ifa_rta, attrlen); ifa_rta = RTA_NEXT(ifa_rta, attrlen)) {
switch (ifa_rta->rta_type) {
case IFA_ADDRESS: {
case IFA_ADDRESS:
if (net->is_p2p_)
continue;
case IFA_LOCAL:
char ipaddr[INET6_ADDRSTRLEN];
if (!is_del_event) {
net->ipaddr_ = inet_ntop(ifa->ifa_family, RTA_DATA(ifa_rta), ipaddr, sizeof(ipaddr));
Expand Down Expand Up @@ -570,7 +578,6 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) {
}
net->dp.emit();
break;
}
}
}
break;
Expand Down

0 comments on commit e4faf25

Please sign in to comment.