safesocket: simplify API.

On unix, we want to provide a full path to the desired unix socket.

On windows, currently we want to provide a TCP port, but someday
we'll also provide a "path-ish" object for a named pipe.

For now, simplify the API down to exactly a path and a TCP port.

Signed-off-by: David Anderson <dave@natulte.net>
This commit is contained in:
David Anderson
2020-02-18 12:33:28 -08:00
committed by Dave Anderson
parent b72e6446e2
commit 4460bd638b
6 changed files with 29 additions and 23 deletions
+7 -1
View File
@@ -39,6 +39,12 @@ const defaultLoginServer = "https://login.tailscale.com"
// Options is the configuration of the Tailscale node agent.
type Options struct {
// SocketPath, on unix systems, is the unix socket path to listen
// on for frontend connections.
SocketPath string
// Port, on windows, is the localhost TCP port to listen on for
// frontend connections.
Port int
// StatePath is the path to the stored agent state.
StatePath string
// AutostartStateKey, if non-empty, immediately starts the agent
@@ -72,7 +78,7 @@ func pump(logf logger.Logf, ctx context.Context, bs *ipn.BackendServer, s net.Co
func Run(rctx context.Context, logf logger.Logf, logid string, opts Options, e wgengine.Engine) error {
bo := backoff.Backoff{Name: "ipnserver"}
listen, _, err := safesocket.Listen("", "Tailscale", "tailscaled", 41112)
listen, _, err := safesocket.Listen(opts.SocketPath, uint16(opts.Port))
if err != nil {
return fmt.Errorf("safesocket.Listen: %v", err)
}