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
+2 -1
View File
@@ -52,6 +52,7 @@ func main() {
log.Printf("fixConsoleOutput: %v\n", err)
}
socket := getopt.StringLong("socket", 0, "/run/tailscale/tailscaled.sock", "path of tailscaled's unix socket")
server := getopt.StringLong("server", 's', "https://login.tailscale.com", "URL to tailcontrol server")
nuroutes := getopt.BoolLong("no-single-routes", 'N', "disallow (non-subnet) routes to single nodes")
routeall := getopt.BoolLong("remote-routes", 'R', "accept routes advertised by remote nodes")
@@ -84,7 +85,7 @@ func main() {
AdvertiseRoutes: adv,
}
c, err := safesocket.Connect("", "Tailscale", "tailscaled", 41112)
c, err := safesocket.Connect(*socket, 0)
if err != nil {
log.Fatalf("safesocket.Connect: %v\n", err)
}
+6
View File
@@ -38,6 +38,7 @@ func main() {
tunname := getopt.StringLong("tun", 0, "ts0", "tunnel interface name")
listenport := getopt.Uint16Long("port", 'p', magicsock.DefaultPort, "WireGuard port (0=autoselect)")
statepath := getopt.StringLong("state", 0, "", "Path of state file")
socketpath := getopt.StringLong("socket", 's', "/run/tailscale/tailscaled.sock", "Path of the service unix socket")
logf := wgengine.RusagePrefixLog(log.Printf)
@@ -56,6 +57,10 @@ func main() {
log.Fatalf("--state is required")
}
if *socketpath == "" {
log.Fatalf("--socket is required")
}
if *debug != "" {
go runDebugServer(*debug)
}
@@ -72,6 +77,7 @@ func main() {
e = wgengine.NewWatchdog(e)
opts := ipnserver.Options{
SocketPath: *socketpath,
StatePath: *statepath,
AutostartStateKey: globalStateKey,
SurviveDisconnects: true,