BoringTun, a Userspace WireGuard Implementation in Rust
blog.cloudflare.com
blog.cloudflare.com
[1] https://lists.zx2c4.com/pipermail/wireguard/2019-March/00404...
Given that WireGuard has been designed to be relatively simple, maybe multiple widely used implementations will make sure it stays that way.
Disclaimer: My employer sponsored a lot of the work with Jason for the windows wireguard port. (Search for "Accelerating Windows Development on https://www.wireguard.com/donations/)
[1] https://lists.zx2c4.com/pipermail/wireguard/2019-March/00403...
I've been testing out wireguard's linux kernel module, but experienced too much jitter due to wireguard not respecting isolcpus.
Probably possible to make the kernel module behave, but working with userspace is so much easier. Wireguard-go seems to behave (the drop in performance is not necessarily a showstopper), although the description says that it shouldn't be used on Linux :-)
Would be nice if a high performance rust implementation can become a real alternative. A userspace implementation shouldn't need to be much slower than a kernel module if network card with kernel bypass is available, if you really need that extra performance.
Nonetheless, it's great that Wireguard have a path to a solid user space implementation that others could build from.
Jason Donenfeld's post about this surprised me when he said the go implementation is flaky. Is the health of the non-kernel parts of wireguard not great? The macOS clients work really well for me.
But we're pretty frequently running into limitations and fighting with the runtime; we've submitted quite a few random patches to it. I think Rust is probably a better-suited language for a high performance and relatively secure WireGuard implementation. Hence, we'd really like to have a strong first-party Rust implementation for the project.
I've created a _wireguard user+group, setup a /dev/tun0 interface to have the _wireguard group with read/write however from the little tracing i've done it looks like I still need root when it tries to do the unix sys call to set the MTU.
They also implemented the noise handshake in a non-generic way tightly coupled to wireguard protocol, again written themselves instead of using an external dependency, which I think is also the approach other wireguard implementations have taken.. which is fine, but harder to independently verify. There's a lot of code there.
Mio, in theory, is not very far off of what I ended up implementing, but it is missing a few features that I really needed, and building those features on top of Mio would be harder than just using epoll/kqueue directly. Also I don't understand the fear people have of using epoll/kqueue. Those are very basic features that every engineer has to know how to use.
So what are the features:
No locks - Mio polls under lock, but epoll/kqueue are multithread safe by nature as long as you use the correct filters. Mio has considerable overhead over pure epoll/kqueue.
No need for tokens, instead I store closure pointers. Real zero overhead. Of course I could cast pointers to usize and use as Mio tokens, but I would still have to build the ownership model on top, which is most of the work anyway.
Timers in Mio run in a thread??? I use platform idiomatic conventions instead, which with kqueue require direct access to kqueue.
Signal handlers, can't make idiomatic one with Mio (or maybe I missed how).
Same with notifications. Could use something awkward like a channel, but prefer idiomatic approach.
However there is no native support for tunnel interfaces in Windows, and we are still thinking about the best way to add full support.
The WireGuard project for example developed a whole new driver just for that. Don't know if we are going to follow that route.
In the interest of honest understanding, what would be reasons not to use WireGuard over existing VPN software (excluding the obvious legacy interop) ?
But user management is exactly as sophisticated as SSH key management. That is to say, easy for 2-3 people, a pain otherwise.
There are attempts at creating UI based user managers for wireguard, and I hope those go somewhere.
I bet the major wireguard-supporting VPN providers have solved this problem for themselves though.
Update: Just wanted to add that I don't think that user management (the work of actually provisioning and managing users) should fall under the umbrella of Wireguard. It's perfect the way it is. But I suspect there will be an ecosystem of tools that come up around it.
(this wouldn't be an issue for my personal use, but it's useful to be aware of it)
It's not yet in a place where I'd recommend it for access VPNs for, say, support staff.
It's more pleasant to use and manage than SSH or SSH tunnels (this is surprising and speaks to what an achievement WireGuard is and why people are so nuts about it), so if you calibrate your tooling/slickness expectations accordingly, you should do fine with it.
I mean a more reliable VPN is probably needed, i.e. something that isn't detectable. However I guess wireguard has all the problems than most VPNs once it's known how it works it's detectable with a DPI. What I probably want to see is a VPN over h2c or over quick, its probably impossible to detect it, it looks like regular web traffic.
Wireguard is better than other VPN software because it's intentionally minimal, with a small set of crypto in-use and simple design choices, leading to small easily-auditable codebases. It's also got a pretty straightforward set of config options without a barrage of tunables, which makes it pretty much impossible to subtly misconfigure things in a way that harms security.
The only way would be to keep the pipe continuously saturated with some padding while you're not sending real data... But is that worth it?
What you want is a slightly different albeit very important problem to solve reliably.
"The name might sound a bit boring but there's a reason for it: BoringTun creates a tunnel by 'boring' it. And it’s a nod to Google’s BoringSSL which strips the complexity out of OpenSSL. We think WireGuard has the opportunity to do the same for legacy VPN protocols like OpenVPN. And we hope BoringTun can be a valuable tool as part of that ecosystem."
so coincidental.