Probably a bit niche, but I pushed Tundra to hex.pm today. It provides a way to create and use non-persistent TUN devices on both Linux and Darwin. It has a consistent api on both platforms, similar to Erlang’s socket
api, although currently only non-blocking i/o is supported.
On Darwin, the TUN device is a socket, and tundra
provides only a very thin layer over the top of the socket
API, once created. On Linux, TUN devices are files so, internally, a NIF is used to manage the file descriptor and its non-blocking i/o.
Due to TUN creation being a privileged operation, a server program is used to do the initial device creation and configuration. This ships in the priv
directory of the application, but how this executable is started is left as an exercise for the reader. On both platforms, the NIF communicates with the server over a domain socket to create and configure the device.