Skip to content

List Wireguard connection as possible VPN#244

Merged
tintou merged 3 commits intoelementary:masterfrom
milouse:feat-support-wireguard
Oct 31, 2023
Merged

List Wireguard connection as possible VPN#244
tintou merged 3 commits intoelementary:masterfrom
milouse:feat-support-wireguard

Conversation

@milouse
Copy link
Contributor

@milouse milouse commented Dec 22, 2021

This MR comes as a complementary work of elementary/settings-network#338 to make wireguard connections first class citizens alongside more classical VPN.

Warning, in order to build this, you need an up-to-date version of libnm (myself I have 1.32.12 installed). The packaged libnm.vapi is outdated, that’s why I take the liberty to remove it from this repository. Even after removing it, the project build just fine.

This MR fixes #245

@milouse
Copy link
Contributor Author

milouse commented Oct 20, 2022

Rebased on last master and fixed all compilation warnings (not due to this MR).

@milouse milouse changed the title List Wireguard connection as possible VPN Draft: List Wireguard connection as possible VPN Dec 14, 2022
@milouse
Copy link
Contributor Author

milouse commented Dec 14, 2022

Flagging it as draft as I just discover an incompatibility bug when listing both OpenVPN and Wireguard connection: When activating OpenVPN connection, the whole panel freeze and make the session crash.

@milouse
Copy link
Contributor Author

milouse commented Dec 14, 2022

Crash fixed, but another problem arised: current widget only list 1 "vpn" active connection at a time, when we can actually have several in parallel. I’ll try to fix that later.

@milouse milouse changed the title Draft: List Wireguard connection as possible VPN List Wireguard connection as possible VPN Dec 15, 2022
@milouse
Copy link
Contributor Author

milouse commented Dec 15, 2022

Fixed done, now the popover allow the connection of several VPN or wireguard connection in parallel.

This MR is open again for review if one is interested?

@danirabbit danirabbit requested a review from a team February 16, 2023 18:28
@danirabbit
Copy link
Member

Hey @milouse apologies for not looking at this sooner! It looks like this branch was touching a number of things outside of just adding wireguard support which probably made it more difficult for someone to review. For future branches try to leave things like cleaning up unrelated deprecation warnings etc for another branch 😀

If you're still interested in working on this, and want to resolve conflicts, I'd love to review it! I've been working recently on revamping VPNs and cleaning up some of the mess that was here so it should be much more straightforward to add wireguard support.

Thanks again!

@milouse
Copy link
Contributor Author

milouse commented Feb 24, 2023

Hi,

I can take time to look again on this. I’ll rebase this branch on your last developments to take them into account.

I agree this branch touch a lot of different thing, but from my point of view, that was required refactoring to improve maintenability of the whole "vpn+wireguard" set of feature. Not sure an MR just refactoring things out of the blue would have make sense for reviewer :/

@danirabbit
Copy link
Member

Refactoring branches are always appreciated! The more things can be broken up into smaller chunks the easier they are to review quickly. You can always leave a description that indicates why a certain refactor makes sense for a future branch etc. I think we've all had that experience of knowing some old code needs to change so we can eventually add a new feature :)

@milouse
Copy link
Contributor Author

milouse commented Jul 24, 2023

In the next months, I’ll take time to have a fresh new looks on this, so you can expect new MR / iteration on the subject. Have a good week ! :)

@milouse
Copy link
Contributor Author

milouse commented Jul 24, 2023

@danirabbit It was finally way much easier than I thought to rebase this MR on master. This is now done, thus feel free to review when you can.

I already use it without any trouble.

* implementation for the signal handlers. */
var _connection = (NM.VpnConnection) ac;
secure = secure || (_connection.get_vpn_state () == NM.VpnConnectionState.ACTIVATED);
_connection.vpn_state_changed.disconnect (update_vpn_connection);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these disconnects helping? I feel like I am missing something here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question… I’m not sure how signaling really works internally. Are callbacks stored in a simple list or a set (i.e. if we connnect again and again the same callback, do we get a full list of duplicated handlers, or does the "connect" method already take care to discard existing handlers when registering? I cannot found anything about this in the documentation, that’s why I did the disconnection myself to ensure we keep only one callback at a time.

Actually, when I did my tests, I discover that without disconnecting previous handlers, I ended with a lot of parallel callback calls after some time (easily testable with a simple log output), that’s why I added this disconnect call before to avoid duplicate. But maybe I missed something.

If one has a good documentation entry about maintaining signal handlers, I’d appreciate!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @Marukesu has made good suggestions for documentation before on the Slack. Maybe he has insight with this?

@milouse
Copy link
Contributor Author

milouse commented Sep 15, 2023

(just rebased on master)

@rasmus91
Copy link

rasmus91 commented Oct 6, 2023

I have tested this on Ubuntu 22.04 with elementary Desktop installed (and will on elementary too, and update here accordingly)

procedure to install:

git clone https://github.com/milouse/wingpanel-indicator-network
cd wingpanel-indicator-network
git switch feat-support-wireguard
meson build --prefix=/usr
cd build
ninja
sudo cp libnetwork.so /usr/lib/x86_64-linux-gnu/wingpanel/libnetwork.so
sudo chmod 644 /usr/lib/x86_64-linux-gnu/wingpanel/libnetwork.so
sudo chown root:root /usr/lib/x86_64-linux-gnu/wingpanel/libnetwork.so
killall io.elementary.wingpanel # to make the indicator reload

any wireguard connection you wish to manage this way should be set up using nm-connection-editor

On Ubuntu with elementary Desktop: It works very well, Only there's a very generic looking network notification coming up when connecting or disconnecting for the wg interface.

On elementary OS: This works even better. When disconnecting the annoying generic looking notification does not pop up (meaning that's probably an ubuntu thing I haven't gotten cleaned up on the other setup.)

Error message is:

io.elementary.w[33492]: DisplayWidget.vala:152: Unknown network state, cannot show the good icon: NETWORK_STATE_FAILED
Copy link
Contributor

@zeebok zeebok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the code looks decent. And Rasmus seemed to do good testing and seems to think it is in good shape! Thanks for the work everybody!

@zeebok
Copy link
Contributor

zeebok commented Oct 26, 2023

Before I merge into main, @milouse are there any more updates to get merged into this or the other repo?

@tintou
Copy link
Member

tintou commented Oct 31, 2023

Works for me!

@tintou tintou merged commit ce7c1a6 into elementary:master Oct 31, 2023
@milouse
Copy link
Contributor Author

milouse commented Nov 2, 2023

Sorry I was in holiday. Glad it’s finally merged :) Hope it will help lot of people :)

Thank you all for reviewing/testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Integrate Wireguard connections alongside other VPNs

5 participants