version: add IsMobile func

And use it control/controlclient.
pull/123/head
Brad Fitzpatrick 4 years ago
parent 11489a6e67
commit 7172f3dbf4

@ -144,10 +144,9 @@ func hostinfoOS() string {
os := runtime.GOOS os := runtime.GOOS
switch os { switch os {
case "darwin": case "darwin":
switch runtime.GOARCH { if version.IsMobile() {
case "arm", "arm64":
return "iOS" return "iOS"
default: } else {
return "macOS" return "macOS"
} }
default: default:

@ -11,12 +11,12 @@ import (
"fmt" "fmt"
"log" "log"
"net" "net"
"runtime"
"strings" "strings"
"time" "time"
"github.com/tailscale/wireguard-go/wgcfg" "github.com/tailscale/wireguard-go/wgcfg"
"tailscale.com/tailcfg" "tailscale.com/tailcfg"
"tailscale.com/version"
"tailscale.com/wgengine/filter" "tailscale.com/wgengine/filter"
) )
@ -154,9 +154,6 @@ func (nm *NetworkMap) UserMap() map[string][]filter.IP {
return rev return rev
} }
var iOS = runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64")
var keepalive = !iOS
const ( const (
UAllowSingleHosts = 1 << iota UAllowSingleHosts = 1 << iota
UAllowSubnetRoutes UAllowSubnetRoutes
@ -278,7 +275,8 @@ func (nm *NetworkMap) _WireGuardConfig(uflags int, dnsOverride []wgcfg.IP, allEn
aips = append(aips, aip) aips = append(aips, aip)
} }
fmt.Fprintf(buf, "AllowedIPs = %s\n", strings.Join(aips, ", ")) fmt.Fprintf(buf, "AllowedIPs = %s\n", strings.Join(aips, ", "))
if keepalive { doKeepAlives := !version.IsMobile()
if doKeepAlives {
fmt.Fprintf(buf, "PersistentKeepalive = 25\n") fmt.Fprintf(buf, "PersistentKeepalive = 25\n")
} }
} }

@ -0,0 +1,15 @@
// 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 version
import "runtime"
// IsMobile reports whether this is a mobile client build.
func IsMobile() bool {
// Good enough heuristic for now, at least until Apple makes
// ARM laptops...
return runtime.GOOS == "android" ||
(runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64"))
}
Loading…
Cancel
Save