cmusatyalab / wireguard-tools

Pure python reimplementation of wireguard-tools
MIT License
24 stars 9 forks source link

Up / Down #2

Open fldv opened 1 year ago

fldv commented 1 year ago

Hi,

Is it planned to be able to mount a Wireguard interface or unmount it ? (Up/Down)

Thanks

jaharkes commented 1 year ago

I wasn't planning on that because those operations were easily done with the existing ip command which I assumed would be already available on most systems.

The iproute2 python package which we already depend on for netlink protocol handling has all the functions that are needed to create and manipulate network interfaces from python in the same way that ip does from the command line. An example of that sort of code is here, https://github.com/cmusatyalab/sinfonia-tier3/blob/main/src/sinfonia_tier3/netns_helper.py#L46

One reason why for my case it wasn't useful for wireguard-tools to have this functionality, is that my code is split across two different network namespaces, the default namespace handles the wireguard tunnel creation and configuration, while the restricted namespace handles things like bringing the interface up and network addresses and routing. This way sensitive configuration items like encryption keys don't have to be exposed in the restricted namespace. But that distinction is a bit specific to my particular use case.

gaby commented 3 months ago

@jaharkes True but ideally if i'm already using Python to configure the Wireguard interface i would also like to manage the interface. Without this functionality I have to make calls to wg-quick up/down.