mirror of
https://github.com/netbirdio/netbird.git
synced 2024-10-05 17:52:09 +02:00
Macos version error (#666)
use sw_vers to retrieve the proper macOS version.
This commit is contained in:
parent
9adadfade4
commit
494e56d1be
@ -4,9 +4,12 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetInfo retrieves and parses the system information
|
// GetInfo retrieves and parses the system information
|
||||||
@ -19,7 +22,12 @@ func GetInfo(ctx context.Context) *Info {
|
|||||||
sysName := string(bytes.Split(utsname.Sysname[:], []byte{0})[0])
|
sysName := string(bytes.Split(utsname.Sysname[:], []byte{0})[0])
|
||||||
machine := string(bytes.Split(utsname.Machine[:], []byte{0})[0])
|
machine := string(bytes.Split(utsname.Machine[:], []byte{0})[0])
|
||||||
release := string(bytes.Split(utsname.Release[:], []byte{0})[0])
|
release := string(bytes.Split(utsname.Release[:], []byte{0})[0])
|
||||||
gio := &Info{Kernel: sysName, OSVersion: release, Core: release, Platform: machine, OS: sysName, GoOS: runtime.GOOS, CPUs: runtime.NumCPU()}
|
version, err := exec.Command("sw_vers", "-productVersion").Output()
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("got an error while retrieving macOS version with sw_vers, error: %s. Using darwin version instead.\n", err)
|
||||||
|
version = []byte(release)
|
||||||
|
}
|
||||||
|
gio := &Info{Kernel: sysName, OSVersion: strings.TrimSpace(string(version)), Core: release, Platform: machine, OS: sysName, GoOS: runtime.GOOS, CPUs: runtime.NumCPU()}
|
||||||
gio.Hostname, _ = os.Hostname()
|
gio.Hostname, _ = os.Hostname()
|
||||||
gio.WiretrusteeVersion = NetbirdVersion()
|
gio.WiretrusteeVersion = NetbirdVersion()
|
||||||
gio.UIVersion = extractUserAgent(ctx)
|
gio.UIVersion = extractUserAgent(ctx)
|
||||||
|
Loading…
Reference in New Issue
Block a user