Python Wrapper for wireguard-tools
Mo Balaa
buddybalaa at gmail.com
Mon Aug 24 21:38:52 CEST 2020
We also wrap wg command and provide a high level config interface via
Python for our personal networking framework, Noteworthy.
See https://github.com/decentralabs/noteworthy/blob/master/plugins/wireguard/noteworthy/wireguard/wg.py
On Mon, Aug 24, 2020 at 2:35 PM Mo Balaa <buddybalaa at gmail.com> wrote:
>
> We also wrap wg command and provide a high level config interface via Python for our personal networking framework Noteworthy.
>
> https://github.com/decentralabs/noteworthy/blob/master/plugins/wireguard/noteworthy/wireguard/wg.py
>
>
> On Mon, Aug 24, 2020 at 14:00 Ryan Whelan <rcwhelan at gmail.com> wrote:
>>
>> At this point, it's very old and not in use, but I once worked on a
>>
>> project that would wrap the `wg` command in python.
>>
>>
>>
>> If helpful, I posted it here:
>>
>> https://gist.github.com/rwhelan/f46d1f6f07df71f1bd1786eda447b97f
>>
>>
>>
>> I don't think its feature complete as it was only used internally for
>>
>> a project that took another direction. But in case it's helpful...
>>
>>
>>
>>
>>
>> On Sat, Aug 22, 2020 at 3:03 PM Andrew Roth <andrew at andrewjroth.com> wrote:
>>
>> >
>>
>> > Hello,
>>
>> >
>>
>> > Recently joined the list, but reviewed the archives as best I could.
>>
>> > I figured before I get too far in writing this, I should ask here.
>>
>> >
>>
>> > I'm looking for a way to create and configure WireGaurd interfaces
>>
>> > programmatically using Python. Has anyone created a Python wrapper
>>
>> > for the wireguard-tools? If not, could I try my hand at it?
>>
>> >
>>
>> > In my research, I was not able to find any true libraries supporting
>>
>> > configuring a WireGuard implementation. Since wireguard-tools [1] is
>>
>> > cross-platform, and Python is cross-platform, I wanted a
>>
>> > cross-platform library to configure WireGuard interfaces. This would
>>
>> > help application programmers or tool developers who want to utilize
>>
>> > WireGuard as part of the application or tool written in Python,
>>
>> > potentially cross-platform.
>>
>> >
>>
>> > I did see wgnlpy [2], but don't think it is a fit since it relies on
>>
>> > Netlink (Linux kernel interface), so it's not cross-platform. I also
>>
>> > found a few other packages on Pypi, but none of them seemed to
>>
>> > interface with the WireGuard module interfaces.
>>
>> >
>>
>> > In the wireguard-tools repository, I noticed the embeddable-wg-library
>>
>> > [3] with C source and header. Python (using CFFI) supports creating
>>
>> > an extension module that is compiled from C sources to directly invoke
>>
>> > the target C function [4]. It claims to be fast, simple, and
>>
>> > platform-agnostic (by that, I mean it can be compiled for any
>>
>> > platform). I am planning on writing a python module to expose the C
>>
>> > functions from the embeddable-wg-library using CFFI.
>>
>> >
>>
>> > Does this make sense? Any comments, gotchas, or limitations?
>>
>> >
>>
>> > Thanks for your time,
>>
>> > Andrew
>>
>> >
>>
>> > [1]: https://git.zx2c4.com/wireguard-tools/about/
>>
>> > [2]: https://github.com/ArgosyLabs/wgnlpy
>>
>> > [3]: https://git.zx2c4.com/wireguard-tools/tree/contrib/embeddable-wg-library
>>
>> > [4]: https://cffi.readthedocs.io/en/latest/overview.html#api-mode-calling-c-sources-instead-of-a-compiled-library
>>
>> >
>>
>> > --
>>
>> >
>>
>> > ~Andrew Roth
>>
>> > http://www.andrewjroth.com
>>
>> >
>>
>> > "Our greatest glory is not in never falling, but in getting up every
>>
>> > time we do." -Confucius
>>
More information about the WireGuard
mailing list