mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-05 07:55:36 +00:00
db85384f9c
One of the current few steps to run Tailscale on gokrazy is to specify the --tun=userspace-networking flag: https://gokrazy.org/userguide/install/tailscale/ Instead, make it the default for now. Later we can change the default to kernel mode if available and fall back to userspace mode like Synology, once #391 is done. Likewise, set default paths for Gokrazy, as its filesystem hierarchy is not the Linux standard one. Instead, use the conventional paths as documented at https://gokrazy.org/userguide/install/tailscale/. Updates #1866 RELNOTE=default to userspace-networking mode on gokrazy Change-Id: I3766159a294738597b4b30629d2860312dbb7609 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
76 lines
2.2 KiB
Go
76 lines
2.2 KiB
Go
// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Package paths returns platform and user-specific default paths to
|
|
// Tailscale files and directories.
|
|
package paths
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"sync/atomic"
|
|
|
|
"tailscale.com/version/distro"
|
|
)
|
|
|
|
// AppSharedDir is a string set by the iOS or Android app on start
|
|
// containing a directory we can read/write in.
|
|
var AppSharedDir atomic.Value
|
|
|
|
// DefaultTailscaledSocket returns the path to the tailscaled Unix socket
|
|
// or the empty string if there's no reasonable default.
|
|
func DefaultTailscaledSocket() string {
|
|
if runtime.GOOS == "windows" {
|
|
return ""
|
|
}
|
|
if runtime.GOOS == "darwin" {
|
|
return "/var/run/tailscaled.socket"
|
|
}
|
|
switch distro.Get() {
|
|
case distro.Synology:
|
|
// TODO(maisem): be smarter about this. We can parse /etc/VERSION.
|
|
const dsm6Sock = "/var/packages/Tailscale/etc/tailscaled.sock"
|
|
const dsm7Sock = "/var/packages/Tailscale/var/tailscaled.sock"
|
|
if fi, err := os.Stat(dsm6Sock); err == nil && !fi.IsDir() {
|
|
return dsm6Sock
|
|
}
|
|
if fi, err := os.Stat(dsm7Sock); err == nil && !fi.IsDir() {
|
|
return dsm7Sock
|
|
}
|
|
case distro.Gokrazy:
|
|
return "/perm/tailscaled/tailscaled.sock"
|
|
}
|
|
if fi, err := os.Stat("/var/run"); err == nil && fi.IsDir() {
|
|
return "/var/run/tailscale/tailscaled.sock"
|
|
}
|
|
return "tailscaled.sock"
|
|
}
|
|
|
|
var stateFileFunc func() string
|
|
|
|
// DefaultTailscaledStateFile returns the default path to the
|
|
// tailscaled state file, or the empty string if there's no reasonable
|
|
// default value.
|
|
func DefaultTailscaledStateFile() string {
|
|
if f := stateFileFunc; f != nil {
|
|
return f()
|
|
}
|
|
if runtime.GOOS == "windows" {
|
|
return filepath.Join(os.Getenv("ProgramData"), "Tailscale", "server-state.conf")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
// MkStateDir ensures that dirPath, the daemon's configurtaion directory
|
|
// containing machine keys etc, both exists and has the correct permissions.
|
|
// We want it to only be accessible to the user the daemon is running under.
|
|
func MkStateDir(dirPath string) error {
|
|
if err := os.MkdirAll(dirPath, 0700); err != nil {
|
|
return err
|
|
}
|
|
|
|
return ensureStateDirPerms(dirPath)
|
|
}
|