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

Add JSON support #82

Closed JordanDeBeer closed 4 years ago

JordanDeBeer commented 4 years ago

This PR makes working with JSON in this library a bit easier.

Firstly, it adds json tags to each struct in wgtypes so that they are serialized to json in a more "json-esque" format.

Secondly, it adds a custom UnmarshalJSON method for wgtypes.Key so that they can be read from JSON.

JordanDeBeer commented 4 years ago

This PR probably needs another test or two based on some work I was doing utilizing the UnmarshalJSON method. Going to see what I can do about writing those and then re-open.

mdlayher commented 4 years ago

I would prefer not to add JSON methods to this package. I don't see this being a particularly common use case and would rather have callers create their own JSON representation, or possibly use something like the upcoming registration methods: https://github.com/golang/go/issues/5901

Thanks for your time, but I'd rather not pursue this.