Closed martin31821 closed 5 years ago
I totally understand why you would want this, but unfortunately it's outside the scope of this library. See the README:
This package implements WireGuard configuration protocol operations, enabling the configuration of existing WireGuard devices. Operations such as creating WireGuard devices, or applying IP addresses to those devices, are out of scope for this package.
You should be able to accomplish this using a route netlink package, such as https://github.com/jsimonetti/rtnetlink. It appears that the proper API for doing so is already in place.
If this type of thing interests you, feel free to join us on #networking on Gophers Slack. There are lots of folks doing networking and netlink things there.
Closing as out of scope for this package.
I feel like importing rtnetlink is a bit too much for creating one interface, so for cases like this I think it's a lot easier to create the interface before starting the go script that controls it, and if there are multiple interfaces just to run multiple scripts. This is easy to set up with docker. Though I understand the need to control interface creation from go.
Either way, there will be a lot of people asking themselves the same question, and some of them might not end up at this ticket, so a reference to rtnetlink could be useful in the readme.
It would be really cool to have support to create and initialize a new wireguard interface. In theory, it should only be neccessary to have a
client.CreateWG(name string) error
method, which creates a blank interface (basically the equivalent of runningip link add dev wg0 type wireguard
)