2021-08-27 11:34:38 +02:00
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2022-05-25 23:25:02 +02:00
|
|
|
"context"
|
2021-08-27 11:34:38 +02:00
|
|
|
"fmt"
|
2022-07-30 11:31:27 +02:00
|
|
|
"golang.org/x/sys/unix"
|
2021-08-27 11:34:38 +02:00
|
|
|
"os"
|
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
|
2022-05-25 23:25:02 +02:00
|
|
|
// GetInfo retrieves and parses the system information
|
|
|
|
func GetInfo(ctx context.Context) *Info {
|
2022-07-30 11:31:27 +02:00
|
|
|
utsname := unix.Utsname{}
|
|
|
|
err := unix.Uname(&utsname)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("getInfo:", err)
|
2021-08-27 11:34:38 +02:00
|
|
|
}
|
2022-07-30 11:31:27 +02:00
|
|
|
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()}
|
2021-08-27 11:34:38 +02:00
|
|
|
gio.Hostname, _ = os.Hostname()
|
2022-05-25 23:25:02 +02:00
|
|
|
gio.WiretrusteeVersion = NetbirdVersion()
|
|
|
|
gio.UIVersion = extractUserAgent(ctx)
|
|
|
|
|
2021-08-27 11:34:38 +02:00
|
|
|
return gio
|
|
|
|
}
|