This is a sample commit for a possible way to make
a Go API that lives alongside UAPI.
The general idea is to add Device and Peer methods
corresponding to UAPI directives, including a way to
look up a peer from a device based on a public key,
as in UAPI.
The UAPI code then deals with parsing and generating textual
input/output, and calls the Go methods to do the work.
This commit also contains a bug fix for a racy access of device.net.port
I will send an independently commit that fixes those directly in UAPI.
This commit is NOT meant to be merged as-is.
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
Any io.Reader will do, and there are no performance concerns here.
This is technically backwards incompatible,
but it is very unlikely to break any existing code.
It is compatible with the existing uses in wireguard-{windows,android,apple}
and also will allow us to slightly simplify it if desired.
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
The sticky socket code stays in the device package for now,
as it reaches deeply into the peer list.
This is the first step in an effort to split some code out of
the very busy device package.
Signed-off-by: David Crawshaw <crawshaw@tailscale.com>