mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-14 19:00:50 +01:00
d1c2b3d703
This prevents the client from needing to use command line tools
29 lines
771 B
Go
29 lines
771 B
Go
package system
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"fmt"
|
|
"golang.org/x/sys/unix"
|
|
"os"
|
|
"runtime"
|
|
)
|
|
|
|
// GetInfo retrieves and parses the system information
|
|
func GetInfo(ctx context.Context) *Info {
|
|
utsname := unix.Utsname{}
|
|
err := unix.Uname(&utsname)
|
|
if err != nil {
|
|
fmt.Println("getInfo:", err)
|
|
}
|
|
sysName := string(bytes.Split(utsname.Sysname[:], []byte{0})[0])
|
|
machine := string(bytes.Split(utsname.Machine[:], []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()}
|
|
gio.Hostname, _ = os.Hostname()
|
|
gio.WiretrusteeVersion = NetbirdVersion()
|
|
gio.UIVersion = extractUserAgent(ctx)
|
|
|
|
return gio
|
|
}
|