From c1d9e41befbcc4ba21679b1a9cf7fb037283bdbf Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 13 Jul 2020 09:23:44 -0700 Subject: [PATCH] cmd/tailscaled: use "Tailscale" as default TUN device name on Windows That's what's used in the Windows GUI version and seems special. If we don't use that, Windows tries to rename it and fails. --- cmd/tailscaled/tailscaled.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cmd/tailscaled/tailscaled.go b/cmd/tailscaled/tailscaled.go index a8db1b39e..9df15bcaa 100644 --- a/cmd/tailscaled/tailscaled.go +++ b/cmd/tailscaled/tailscaled.go @@ -41,6 +41,17 @@ // later, the global state key doesn't look like a username. const globalStateKey = "_daemon" +// defaultTunName returns the default tun device name for the platform. +func defaultTunName() string { + switch runtime.GOOS { + case "openbsd": + return "tun" + case "windows": + return "Tailscale" + } + return "tailscale0" +} + func main() { // We aren't very performance sensitive, and the parts that are // performance sensitive (wireguard) try hard not to do any memory @@ -50,15 +61,10 @@ func main() { debug.SetGCPercent(10) } - defaultTunName := "tailscale0" - if runtime.GOOS == "openbsd" { - defaultTunName = "tun" - } - cleanup := getopt.BoolLong("cleanup", 0, "clean up system state and exit") fake := getopt.BoolLong("fake", 0, "fake tunnel+routing instead of tuntap") debug := getopt.StringLong("debug", 0, "", "Address of debug server") - tunname := getopt.StringLong("tun", 0, defaultTunName, "tunnel interface name") + tunname := getopt.StringLong("tun", 0, defaultTunName(), "tunnel interface name") listenport := getopt.Uint16Long("port", 'p', magicsock.DefaultPort, "WireGuard port (0=autoselect)") statepath := getopt.StringLong("state", 0, paths.DefaultTailscaledStateFile(), "Path of state file") socketpath := getopt.StringLong("socket", 's', paths.DefaultTailscaledSocket(), "Path of the service unix socket")