WireGuard / wgctrl-go

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

Peer to PeerConfig method #71

Closed muhlemmer closed 4 years ago

muhlemmer commented 5 years ago

I'm writing a getter/ setter kind of config app for which I need to convert wgtypes.Peer to wgtypes.PeerConfig. I'm planning to write a helper function for that. If you guys are interested, I can make it a method of wgtypes.Peer and send a pull request instead.

I'm thinking of the following design:

// PeerConfig converts Peer into a config.
// Empty fields become nil in output, so those properties will not be reconfigured.
// Remove field in output is always false.
// ReplaceAllowedIPs configures the likewise named field in output.
func(p *Peer)PeerConfig(ReplaceAllowedIPs bool) PeerConfig
mdlayher commented 5 years ago

I think at this time, I'd prefer to keep the API small and focused. In addition, I think some of the configuration structures could use some more work (see #7).

If this ends up being a popular request, I will reconsider though.

muhlemmer commented 5 years ago

Ok. I already have the helper function in my project. Is was no biggie. The only two tests I had to do where for PresharedKey and PersistentKeepaliveInterval. The rest where already compatible types. Let me know whenever you change your mind.

If time allows I will look into #7.

mdlayher commented 4 years ago

Closing due to no further feedback for a month.