Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network module rework #1106

Merged
merged 7 commits into from
May 21, 2021
Merged

Network module rework #1106

merged 7 commits into from
May 21, 2021

Conversation

tperard
Copy link
Contributor

@tperard tperard commented May 15, 2021

This series of patches should fix most issue related to the network module not showing the current network state and some other issues. It should hopefully fixes #388 #494 #511.

Fix modules starting with no text, but not hidding.

Start with some "text" in the module's label_, update() will then
update it. Since the text should be different, update() will be able
to show or hide the event_box_. This is to work around the case where
the module start with no text, but the the event_box_ is shown.
When more than one message is available to read on the ev_sock_
socket, only the first one is read.

Make some changes to be able to read all the messages available by
setting the socket to non-blocking. This way we can detect when
there's nothing left to read and loop back to wait with epoll.
Instead of using an alternative way to list all links in order to
choose one when an "interface" is in the configuration, we can ask for
a dump of all interface an reuse the handleEvents() function.

This patch also start to rework the handleEvents() function to grab
more information out of each event, like the interface name.
In order to get the IP address of an interface, we can get the
information out of NEWADDR events without needed to call getifaddrs().
And when now events are expected, we can requests a dump of all
addresses and handle addresses changes the same way via handleEvents()
only.
Last part of the rework of handleEvents(), this time we take the
getExternalInterface() function and add it to the handleEvents()
function. That way, waybar can react immediately when a new "external
interface" is available and doesn't need to probe. Also that avoid to
have two different functions consuming from the same socket and we
don't need to recode some of the functions that are already available
via libnl (to send and receive messages).
IFLA_CARRIER allows to know when a cable is plugged to the Ethernet
card or when the WiFi is connected. If there's no carrier, the
interface will be considered disconnected.
@Alexays
Copy link
Owner

Alexays commented May 16, 2021

Hi thanks for the rework!
@pedrocr @niktob560 @tobiasjakobi @hajdamak @husam212
Can you confirm that fixes your pbs? :)

@Alexays
Copy link
Owner

Alexays commented May 16, 2021

LGTM, love this rework!
Thanks @tperard!

@Alexays
Copy link
Owner

Alexays commented May 16, 2021

Will likely also fix #987 #986 #816

@tperard tperard closed this May 17, 2021
@tperard tperard deleted the network-module-reword branch May 17, 2021 18:28
@tperard tperard restored the network-module-reword branch May 17, 2021 18:28
@tperard
Copy link
Contributor Author

tperard commented May 17, 2021

:-(, I've only try to rename the branch, I was hoping it wouldn't close the pull request.

@tperard tperard reopened this May 17, 2021
@tperard tperard changed the title Network module reword Network module rework May 17, 2021
@tperard
Copy link
Contributor Author

tperard commented May 17, 2021

I don't know if the patches would fix #987, I think that going to need testing. But if the "tun*" interface is deleted, and then another one is created, I think that would work.

For #986, that fixed by 9357a6c.

@Alexays Alexays merged commit f78a802 into Alexays:master May 21, 2021
@Alexays
Copy link
Owner

Alexays commented May 21, 2021

Thanks!

@maximbaz
Copy link
Contributor

Wow thanks for your work!
Given how many issues this got solved, maybe warrants a new release? 😉

@Alexays
Copy link
Owner

Alexays commented May 22, 2021

Yep @maximbaz!

@tperard tperard deleted the network-module-reword branch June 8, 2021 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Network sometimes shows as disconnected when it's not
3 participants