mirror of
https://github.com/tailscale/tailscale.git
synced 2026-12-06 23:36:34 +09:00
all: add initial Haiku support (userspace networking only)
This gets "go install ./cmd/tailscale{,d}" building and working on
Haiku (https://www.haiku-os.org/) with its Go port from
github.com/korli/go. tailscaled defaults to userspace networking
there (no TUN support yet).
golang.org/x/sys/unix doesn't support Haiku and Haiku's std net
package can't enumerate interfaces, so netmon's AnyInterfaceUp always
reports true on Haiku, like it does on js and tamago. Without
interface enumeration, Haiku nodes only use DERP for now;
net.Interfaces can be fixed in Haiku's Go port.
Then update various paths, and tweak build tags like we did for other
platforms in the past.
Updates #22937
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Change-Id: I50497d244e45d6a25dc231b6026796ce254f8cd3
This commit is contained in:
1 parent
36780d60ef
commit
d451c68136
19 files changed
+51
-17
No files matched your search
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_flashappliance
|
||||
//go:build !ts_omit_flashappliance && !haiku
|
||||
|
||||
package cli
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build ts_omit_flashappliance
|
||||
//go:build ts_omit_flashappliance || haiku
|
||||
|
||||
package cli
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_flashappliance && !linux && !darwin
|
||||
//go:build !ts_omit_flashappliance && !linux && !darwin && !haiku
|
||||
|
||||
package cli
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_flashappliance
|
||||
//go:build !ts_omit_flashappliance && !haiku
|
||||
|
||||
package cli
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build ts_omit_flashappliance
|
||||
//go:build ts_omit_flashappliance || haiku
|
||||
|
||||
package cli
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !wasm && !windows && !plan9
|
||||
//go:build !wasm && !windows && !plan9 && !haiku
|
||||
|
||||
package cli
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ func defaultTunName() string {
|
||||
return "utun"
|
||||
case "plan9":
|
||||
return "auto"
|
||||
case "aix", "solaris", "illumos":
|
||||
case "aix", "solaris", "illumos", "haiku":
|
||||
return "userspace-networking"
|
||||
case "linux":
|
||||
if buildfeatures.HasSynology && buildfeatures.HasNetstack && distro.Get() == distro.Synology {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_drive
|
||||
//go:build !haiku && !ts_omit_drive
|
||||
|
||||
package main
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_drive
|
||||
//go:build !haiku && !ts_omit_drive
|
||||
|
||||
package condregister
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_posture
|
||||
//go:build !haiku && !ts_omit_posture
|
||||
|
||||
package condregister
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_logtail && (wasm || plan9 || tamago)
|
||||
//go:build !ts_omit_logtail && (wasm || plan9 || tamago || haiku)
|
||||
|
||||
package filch
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_logtail && !windows && !wasm && !plan9 && !tamago
|
||||
//go:build !ts_omit_logtail && !windows && !wasm && !plan9 && !tamago && !haiku
|
||||
|
||||
package filch
|
||||
|
||||
|
||||
+1
-1
@@ -532,7 +532,7 @@ func (s *State) HasPAC() bool { return s != nil && s.PAC != "" }
|
||||
|
||||
// AnyInterfaceUp reports whether any interface seems like it has Internet access.
|
||||
func (s *State) AnyInterfaceUp() bool {
|
||||
if runtime.GOOS == "js" || runtime.GOOS == "tamago" {
|
||||
if runtime.GOOS == "js" || runtime.GOOS == "tamago" || runtime.GOOS == "haiku" {
|
||||
return true
|
||||
}
|
||||
return s != nil && (s.HaveV4 || s.HaveV6)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build aix || solaris || illumos
|
||||
//go:build aix || solaris || illumos || haiku
|
||||
|
||||
package tstun
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !wasm && !tamago && !aix && !solaris && !illumos
|
||||
//go:build !wasm && !tamago && !aix && !solaris && !illumos && !haiku
|
||||
|
||||
// Package tstun creates a tuntap device, working around OS-specific quirks if
|
||||
// necessary.
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build haiku
|
||||
|
||||
package paths
|
||||
|
||||
import "syscall"
|
||||
|
||||
// accessRW reports whether path is readable and writable by the current user.
|
||||
//
|
||||
// golang.org/x/sys/unix lacks Access on Haiku, so this uses syscall instead.
|
||||
func accessRW(path string) error {
|
||||
const rOK, wOK = 4, 2
|
||||
return syscall.Access(path, rOK|wOK)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !windows && !wasm && !plan9 && !tamago && !haiku
|
||||
|
||||
package paths
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
// accessRW reports whether path is readable and writable by the current user.
|
||||
func accessRW(path string) error {
|
||||
return unix.Access(path, unix.O_RDWR)
|
||||
}
|
||||
@@ -62,6 +62,10 @@ func DefaultTailscaledSocket() string {
|
||||
if runtime.GOOS == "plan9" {
|
||||
return "/srv/tailscaled.sock"
|
||||
}
|
||||
if runtime.GOOS == "haiku" {
|
||||
// Haiku has no /var/run; /var is a symlink to /boot/system/var.
|
||||
return "/boot/system/var/run/tailscale/tailscaled.sock"
|
||||
}
|
||||
if runtime.GOOS == "android" {
|
||||
// Android (e.g. a userspace tailscaled under Termux) has no /var,
|
||||
// and the cwd-relative fallback below only works when the daemon
|
||||
|
||||
+3
-2
@@ -11,7 +11,6 @@ import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"tailscale.com/version/distro"
|
||||
)
|
||||
|
||||
@@ -33,6 +32,8 @@ func statePath() string {
|
||||
return "/Library/Tailscale/tailscaled.state"
|
||||
case "aix":
|
||||
return "/var/tailscale/tailscaled.state"
|
||||
case "haiku":
|
||||
return "/boot/system/var/tailscale/tailscaled.state"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
@@ -49,7 +50,7 @@ func stateFileUnix() string {
|
||||
|
||||
try := path
|
||||
for range 3 { // check writability of the file, /var/lib/tailscale, and /var/lib
|
||||
err := unix.Access(try, unix.O_RDWR)
|
||||
err := accessRW(try)
|
||||
if err == nil {
|
||||
return path
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user