elementary / switchboard-plug-network

Switchboard Network Plug
GNU General Public License v3.0
20 stars 23 forks source link

Support Wireguard as a VPN connection #338

Closed milouse closed 8 months ago

milouse commented 1 year ago

This MR is an up-to-date (continuously rebased) follow up of the #302 MR plus some little adjustments.

From my point of view every thing is working as expected, but I’m open to discussion :)

crisconru commented 1 year ago

Is this not moving forward? Wireguard is included even in Linux Kernel. It would be really nice that the Elementary OS supported by default. Since I used Wireguard for the first time I left OpenVPN. It's a bit pity when you try to add a Wireguard connection and it gives you an error.

milouse commented 11 months ago

@danirabbit I just rebase this MR on master. Do you mind have a look at it? I’d be great to have it merged. It’d help a lot for a day to day work with wireguard.

This MR is unrelated with the other I opened for the wingpanel applet. This MR build just fine and works exactly as expected.

Thank you very much.

zeebok commented 9 months ago

From what I can see here, the code looks alright. I do not have a way to quickly test this. Maybe @danirabbit can or knows somebody who can?

milouse commented 9 months ago

(rebase are better to read in a MR than wild merge. Do not hesitate to ask for a rebase :) )

rasmus91 commented 9 months ago

Hey, naive question but should I be able to build and install this on the current version of elementary OS, or does this need to be on a newer build/release?

I have a wireguard config setup to be used with wgquick but it isn't picked up by the network manager. I can't see it in the switchboard plug or the wingpanel indicator. And as far as I can tell, this does not allow one to create WG configs from the switchboard.

milouse commented 9 months ago

Yes, you can have a try. The most simple way to test it is to do the following:

  1. First, be sure to make a backup of the current switchboard network plug: cp /usr/lib/switchboard/network/libnetworking.so ~/
  2. Ensure to close all instances of switchboard (settings app)
  3. Follow the instruction on the README. You might have to install the listed build dependencies first.
  4. Once the build suceeds, you should find a fresh libnetworking.so file in the ./build/src subfolder. Copy this file in /usr/lib/switchboard/network (overwriting the packaged one).

Nothing more to do. Try to start the settings app and go to the network section. You should see any wireguard configuration there. If anything goes wrong (settings app crashes…) just replace your built libnetworking.so file with the backup you made on step 1 and everything will come back as before.

That said, I’m not sure what "wg-quick" really is. The current MR only deals with wireguard connection configured through NetworkManager (i.e. your wireguard config must be setup/appear in nm-connection-editor).

rasmus91 commented 9 months ago
  1. cp /usr/lib/switchboard

The directory there doesn't even exist. rather: /usr/lib/x86_64-linux-gnu/switchboard/network/libnetworking.so

But replacing that does not seem to do the trick. ( my wireguard config is visible as home with nm-connection-editor). And what i mean by the trick, is that I can neither see my existing wireguard conf or create a new one.

wg-quick is just a commandline tool for quickly bringing up a wireguard config

milouse commented 9 months ago

On which system are you? I’m on archlinux on my side, the install path to switchboard libs can vary from one distribution to another. For the same reason, you might have to change a little the README instruction to match your distribution environment.

But if it compiled without any error and produces a .so file in the end, it’s weird that you don’t see your home connection in the VPN list of switchboard. Maybe you’ll need to log-out/log in again your user session to make it works? Just in case (sorry for the stupid question), are you sure you cloned my "wireguard" branch from my own cloned repository (and not build from this repository) ?

rasmus91 commented 9 months ago

Right, I figured it out. But for anyone reading this:

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/switchboard-plug-network.git
cd switchboard-plug-network
git switch wireguard
meson build --prefix=/usr
cd build
ninja
sudo cp src/libnetworking.so /usr/lib/x86_64-linux-gnu/switchboard/network/libnetworking.so
sudo chmod 644 /usr/lib/x86_64-linux-gnu/switchboard/network/libnetworking.so
sudo chown root:root /usr/lib/x86_64-linux-gnu/switchboard/network/libnetworking.so

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. On elmentary OS: It also works very well.

I've seen no inconsistency in functionality on either system, it just works.