WireGuard / wgctrl-go

Package wgctrl enables control of WireGuard interfaces on multiple platforms.
https://godoc.org/golang.zx2c4.com/wireguard/wgctrl
MIT License
730 stars 85 forks source link

Add config support for wg-quick types #26

Closed nmiculinic closed 5 years ago

nmiculinic commented 5 years ago

I'd love if wireguardctrl supported wg-quick configuration options in wgtypes.Config.

I'm mostly interested in:

I can open rudimentary PR for this

mdlayher commented 5 years ago

This is an interesting idea, but to my knowledge, these operations are more so the domain of route netlink and other OS-specific APIs, and not related to the actual WireGuard device implementations (generic netlink, userspace, etc.).

I think it'd make more sense to create/delete WireGuard interfaces and set IP/link parameters in another package, in order to keep the scope of this one focused on managing parameters of existing links.

mdlayher commented 5 years ago

Closing as out of scope, per https://github.com/mdlayher/wireguardctrl/pull/27#issuecomment-476317106.

nmiculinic commented 5 years ago

How about having the address at least? That's the part what's hardest for me since I'm not that experiences with netlink socket (( and that's the one I'm actually missing the most ))

mdlayher commented 5 years ago

I'm not entirely sure what you mean. Getting or setting the IP address would be done using a route netlink operation on Linux, or other OS-specific operation on another platform.

You'd need to pull in a different library such as https://github.com/vishvananda/netlink or https://gitlab.com/mergetb/tech/rtnl to set the IP address anyway. You could get the device's IP address with net.Interface from the standard library.

nmiculinic commented 5 years ago

Does this package handle the routes via netlink socket? Or not?

nmiculinic commented 5 years ago

I mean when you do wg-quick up it setups the wireguard device, routing table and adds ip addresses on the interface

mdlayher commented 5 years ago

Those operations are not handled by this package. This package only gets and sets data available in the generic netlink and userspace interfaces:

https://www.wireguard.com/xplatform/ https://godoc.org/github.com/mdlayher/wireguardctrl/wgtypes#Config https://godoc.org/github.com/mdlayher/wireguardctrl/wgtypes#Device