Firezone releases Sanstun, a sans-IO WireGuard implementation in Rust
After two years of patching boringtun, Firezone built a cleaner WireGuard state machine designed for parallel-friendly APIs and testability.
What to know
- Firezone released Sanstun, a new WireGuard implementation in Rust built on sans-IO principles that separate business logic from IO and timing side effects.
- The project emerged from Firezone's experience maintaining 70+ patches to boringtun while trying to retain upstream API compatibility—a constraint that became unsustainable as product needs evolved.
- Sanstun eliminates internal buffering and automatic session management, moving those responsibilities to the caller for simpler, more testable APIs that better align with sans-IO design.
Firezone Developer of Sanstun
How it unfolded 1 development · click the chart to see its coverage articlesposts
-
1
Sanstun removes internal buffering for simpler, more testable APIs
A key design decision in Sanstun was eliminating internal buffering—boringtun automatically established sessions and buffered packets, but Sanstun puts that responsibility on the caller. This simplifies both the interface and implementation, and aligns with sans-IO principles by removing side effects from the library.
“Just don't buffer in the library. It simplifies the interface and the implementation on both sides.”
— Firezone -
> Async is not I/O. It can be used for I/O, but it's just a way of writing pure, deterministic state machines that keeps a logical flow together instead of scattered over a bunch of transitions.I argue that it is exactly opposite. Blocking threads are a much more natural way of thinking about concurrency.Quote from the erlang creator Joe…
2 more of the top 3 · 10 posts in this stretch
-
> flow that crosses several state transitions (and may have other disjoint parts of the state updated in the meantime, via other transitions) now has to be rewritten as a (series of) state transitions, and can't be called from a blocking functionThis is incorrect. You can easily call that flow from a blocking function, just call it in a loop.What…
-
In principle, you are right. Async is not I/O. And yes, `async` functions compile to a deterministic state machine.The problem is, the moment you use `async`, your state machine reduces down to one API: `poll`. What if I want to change some state in-between two state transitions (i.e. between two `await` points)? Now I have to wire-in a channel to…
-
-
background
Firezone details motivations: two years of boringtun patches — Firezone explained that after adopting boringtun for WireGuard, they found themselves maintaining over 70 patches to add features and fix edge cases while trying to keep upstream compatibility. As product requirements evolved, retaining 100% API compatibility became increasingly difficult, leading to the decision to build Sanstun from scratch.
-
background
Firezone announces Sanstun, a sans-IO WireGuard implementation — Firezone released Sanstun, a Rust implementation of the WireGuard state machine built on sans-IO principles. The library separates IO and side-effects (including time and randomness) from business logic, enabling easier testing and composition while avoiding function coloring problems.
What people are saying 7 voices from 1 site · best of 10 · verbatim
- Oct 31
-
Without actual code solving an actual problem discussing this is all a bit wishy washy, but I think you're mixing 'levels'.The sans-io design here is about building reusable parts that any runtime or thread can drive and incorporate into the colored interface they expose.Function coloring is about (the annoyance when) composing interfaces designed…
-
I've recently been developing a VPN Manager implementation using Rust, and the underlying architecture also uses WireGuard. Currently, I'm using WireGuard gotatun developed by Mullvad.I wonder if you've tested any related data, such as performance curves, connection jitter, and so on, as well as things like security implementations.
- Oct 30
-
One of the fundamentally great things about the Wireguard protocol is the simplicity. A small codebase can implement it, and that’s lead to some great libraries and innovation.Another great (and subtle) thing is the monotonically increasing sequence number. Note that it isn’t incrementing, like DTLS. This small thing makes it so much easier to…
-
It was all going great until I read> The design also avoids problems like function coloring and plays well with Rust's ownership rules.Async is not I/O. It can be used for I/O, but it's just a way of writing pure, deterministic state machines that keeps a logical flow together instead of scattered over a bunch of transitions.Even if you choose to…
-
From their website about their product:> Hardware does the heavy lifting.> Your operating system and network card take over the repetitive jobs whenever they can. Your CPU gets room to breathe, and your battery stays full longer.Where does this operating system run? Where does the power come from to run it if not battery?Pure rubbish ai slop.While…
-
Sweet, this is basically how I design my protocol implementations in rust as well.Way more testable, the bulk can be shared between async and blocking IO, it's a lot easier to completely ban unsafe in your dependencies (excepting std and core), etc.
-
Mullvad spun their own implementation off of boringtun as well (called gotatun[0])[0]