mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-19 05:02:34 +00:00
version: move runtime.OS to tailscale OS mapping func to version
So other code can use this without duplicating the policy.
This commit is contained in:
parent
c14bc028ac
commit
4524dcf51e
@ -17,7 +17,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -140,26 +139,12 @@ func NewDirect(opts Options) (*Direct, error) {
|
|||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func hostinfoOS() string {
|
|
||||||
os := runtime.GOOS
|
|
||||||
switch os {
|
|
||||||
case "darwin":
|
|
||||||
if version.IsMobile() {
|
|
||||||
return "iOS"
|
|
||||||
} else {
|
|
||||||
return "macOS"
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return os
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewHostinfo() *tailcfg.Hostinfo {
|
func NewHostinfo() *tailcfg.Hostinfo {
|
||||||
hostname, _ := os.Hostname()
|
hostname, _ := os.Hostname()
|
||||||
return &tailcfg.Hostinfo{
|
return &tailcfg.Hostinfo{
|
||||||
IPNVersion: version.LONG,
|
IPNVersion: version.LONG,
|
||||||
Hostname: hostname,
|
Hostname: hostname,
|
||||||
OS: hostinfoOS(),
|
OS: version.OS(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,3 +13,15 @@ func IsMobile() bool {
|
|||||||
return runtime.GOOS == "android" ||
|
return runtime.GOOS == "android" ||
|
||||||
(runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64"))
|
(runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OS returns runtime.GOOS, except instead of returning "darwin" it
|
||||||
|
// returns "iOS" or "macOS".
|
||||||
|
func OS() string {
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
if IsMobile() {
|
||||||
|
return "iOS"
|
||||||
|
}
|
||||||
|
return "macOS"
|
||||||
|
}
|
||||||
|
return runtime.GOOS
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user