mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-23 00:23:36 +01:00
efbb5acf63
* moved wiretrustee version from main to system.info * added wiretrustee version for all supported platforms * typo corrected * refactor: use single WiretrusteeVersion() func to get version of the client Co-authored-by: braginini <bangvalo@gmail.com>
38 lines
833 B
Go
38 lines
833 B
Go
package system
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"os/exec"
|
|
"runtime"
|
|
"strings"
|
|
)
|
|
|
|
func GetInfo() *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 = WiretrusteeVersion()
|
|
|
|
return gio
|
|
}
|