mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-28 01:28:56 +01:00
94fbfcdb85
Send Desktop UI client version as user-agent to daemon This is sent on every login request to the management Parse the GRPC context on the system package and retrieves the user-agent Management receives the new UIVersion field and store in the Peer's system meta
41 lines
953 B
Go
41 lines
953 B
Go
package system
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"os"
|
|
"os/exec"
|
|
"runtime"
|
|
"strings"
|
|
)
|
|
|
|
// GetInfo retrieves and parses the system information
|
|
func GetInfo(ctx context.Context) *Info {
|
|
cmd := exec.Command("cmd", "ver")
|
|
cmd.Stdin = strings.NewReader("some")
|
|
var out bytes.Buffer
|
|
var stderr bytes.Buffer
|
|
cmd.Stdout = &out
|
|
cmd.Stderr = &stderr
|
|
err := cmd.Run()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
osStr := strings.Replace(out.String(), "\n", "", -1)
|
|
osStr = strings.Replace(osStr, "\r\n", "", -1)
|
|
tmp1 := strings.Index(osStr, "[Version")
|
|
tmp2 := strings.Index(osStr, "]")
|
|
var ver string
|
|
if tmp1 == -1 || tmp2 == -1 {
|
|
ver = "unknown"
|
|
} else {
|
|
ver = osStr[tmp1+9 : tmp2]
|
|
}
|
|
gio := &Info{Kernel: "windows", OSVersion: ver, Core: ver, Platform: "unknown", OS: "windows", GoOS: runtime.GOOS, CPUs: runtime.NumCPU()}
|
|
gio.Hostname, _ = os.Hostname()
|
|
gio.WiretrusteeVersion = NetbirdVersion()
|
|
gio.UIVersion = extractUserAgent(ctx)
|
|
|
|
return gio
|
|
}
|