mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-01 14:05:39 +00:00
all: prepare for GOOS=ios in Go 1.16
Work with either way for now on iOS (darwin/arm64 vs ios/arm64). In February when Go 1.16 comes out we'll have a universal binary for darwin/arm64 (macOS) and will drop support for Go 1.15 and its darwin/amd64 meaning iOS. (it'll mean macOS). Context: * https://tip.golang.org/doc/go1.16#darwin * https://github.com/golang/go/issues/38485 * https://github.com/golang/go/issues/42100
This commit is contained in:
parent
258b680bc5
commit
19b0cfe89e
@ -1549,7 +1549,8 @@ func (b *LocalBackend) TestOnlyPublicKeys() (machineKey tailcfg.MachineKey, node
|
|||||||
// clients. We can't do that until 1.0.x is no longer supported.
|
// clients. We can't do that until 1.0.x is no longer supported.
|
||||||
func temporarilySetMachineKeyInPersist() bool {
|
func temporarilySetMachineKeyInPersist() bool {
|
||||||
//lint:ignore S1008 for comments
|
//lint:ignore S1008 for comments
|
||||||
if runtime.GOOS == "darwin" || runtime.GOOS == "android" {
|
switch runtime.GOOS {
|
||||||
|
case "darwin", "ios", "android":
|
||||||
// iOS, macOS, Android users can't downgrade anyway.
|
// iOS, macOS, Android users can't downgrade anyway.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ func preferGoResolver() bool {
|
|||||||
// There does not appear to be a local resolver running
|
// There does not appear to be a local resolver running
|
||||||
// on iOS, and NetworkExtension is good at isolating DNS.
|
// on iOS, and NetworkExtension is good at isolating DNS.
|
||||||
// So do not use the Go resolver on macOS/iOS.
|
// So do not use the Go resolver on macOS/iOS.
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" || runtime.GOOS == "ios" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"runtime"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"tailscale.com/version"
|
"tailscale.com/version"
|
||||||
@ -34,7 +33,7 @@ type Poller struct {
|
|||||||
// NewPoller returns a new portlist Poller. It returns an error
|
// NewPoller returns a new portlist Poller. It returns an error
|
||||||
// if the portlist couldn't be obtained.
|
// if the portlist couldn't be obtained.
|
||||||
func NewPoller() (*Poller, error) {
|
func NewPoller() (*Poller, error) {
|
||||||
if runtime.GOOS == "darwin" && version.IsMobile() {
|
if version.OS() == "iOS" {
|
||||||
return nil, errors.New("not available on iOS")
|
return nil, errors.New("not available on iOS")
|
||||||
}
|
}
|
||||||
p := &Poller{
|
p := &Poller{
|
||||||
|
@ -19,7 +19,7 @@ func rusageMaxRSS() float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rss := float64(ru.Maxrss)
|
rss := float64(ru.Maxrss)
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" || runtime.GOOS == "ios" {
|
||||||
rss /= 1 << 20 // ru_maxrss is bytes on darwin
|
rss /= 1 << 20 // ru_maxrss is bytes on darwin
|
||||||
} else {
|
} else {
|
||||||
// ru_maxrss is kilobytes elsewhere (linux, openbsd, etc)
|
// ru_maxrss is kilobytes elsewhere (linux, openbsd, etc)
|
||||||
|
@ -10,17 +10,16 @@
|
|||||||
func IsMobile() bool {
|
func IsMobile() bool {
|
||||||
// Good enough heuristic for now, at least until Apple makes
|
// Good enough heuristic for now, at least until Apple makes
|
||||||
// ARM laptops...
|
// ARM laptops...
|
||||||
return runtime.GOOS == "android" ||
|
return runtime.GOOS == "android" || isIOS
|
||||||
(runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OS returns runtime.GOOS, except instead of returning "darwin" it
|
// OS returns runtime.GOOS, except instead of returning "darwin" it
|
||||||
// returns "iOS" or "macOS".
|
// returns "iOS" or "macOS".
|
||||||
func OS() string {
|
func OS() string {
|
||||||
|
if isIOS {
|
||||||
|
return "iOS"
|
||||||
|
}
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
if IsMobile() {
|
|
||||||
return "iOS"
|
|
||||||
}
|
|
||||||
return "macOS"
|
return "macOS"
|
||||||
}
|
}
|
||||||
return runtime.GOOS
|
return runtime.GOOS
|
||||||
|
9
version/prop_ios.go
Normal file
9
version/prop_ios.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// +build ios
|
||||||
|
|
||||||
|
package version
|
||||||
|
|
||||||
|
const isIOS = true
|
9
version/prop_notios.go
Normal file
9
version/prop_notios.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// +build !ios
|
||||||
|
|
||||||
|
package version
|
||||||
|
|
||||||
|
const isIOS = false
|
@ -397,7 +397,7 @@ func (e *userspaceEngine) handleLocalPackets(p *packet.Parsed, t *tstun.TUN) fil
|
|||||||
return filter.Drop
|
return filter.Drop
|
||||||
}
|
}
|
||||||
|
|
||||||
if runtime.GOOS == "darwin" && e.isLocalAddr(p.DstIP4) {
|
if (runtime.GOOS == "darwin" || runtime.GOOS == "ios") && e.isLocalAddr(p.DstIP4) {
|
||||||
// macOS NetworkExtension directs packets destined to the
|
// macOS NetworkExtension directs packets destined to the
|
||||||
// tunnel's local IP address into the tunnel, instead of
|
// tunnel's local IP address into the tunnel, instead of
|
||||||
// looping back within the kernel network stack. We have to
|
// looping back within the kernel network stack. We have to
|
||||||
@ -609,8 +609,7 @@ func forceFullWireguardConfig(numPeers int) bool {
|
|||||||
// On iOS with large networks, it's critical, so turn on trimming.
|
// On iOS with large networks, it's critical, so turn on trimming.
|
||||||
// Otherwise we run out of memory from wireguard-go goroutine stacks+buffers.
|
// Otherwise we run out of memory from wireguard-go goroutine stacks+buffers.
|
||||||
// This will be the default later for all platforms and network sizes.
|
// This will be the default later for all platforms and network sizes.
|
||||||
iOS := runtime.GOOS == "darwin" && version.IsMobile()
|
if numPeers > 50 && version.OS() == "iOS" {
|
||||||
if iOS && numPeers > 50 {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user