mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-12 18:00:49 +01:00
9bc7b9e897
This PR implements the following posture checks: * Agent minimum version allowed * OS minimum version allowed * Geo-location based on connection IP For the geo-based location, we rely on GeoLite2 databases which are free IP geolocation databases. MaxMind was tested and we provide a script that easily allows to download of all necessary files, see infrastructure_files/download-geolite2.sh. The OpenAPI spec should extensively cover the life cycle of current version posture checks.
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
//go:build ios
|
|
// +build ios
|
|
|
|
package system
|
|
|
|
import (
|
|
"context"
|
|
"runtime"
|
|
|
|
"github.com/netbirdio/netbird/version"
|
|
)
|
|
|
|
// GetInfo retrieves and parses the system information
|
|
func GetInfo(ctx context.Context) *Info {
|
|
|
|
// Convert fixed-size byte arrays to Go strings
|
|
sysName := extractOsName(ctx, "sysName")
|
|
swVersion := extractOsVersion(ctx, "swVersion")
|
|
|
|
gio := &Info{Kernel: sysName, OSVersion: swVersion, Platform: "unknown", OS: sysName, GoOS: runtime.GOOS, CPUs: runtime.NumCPU(), KernelVersion: swVersion}
|
|
gio.Hostname = extractDeviceName(ctx, "hostname")
|
|
gio.WiretrusteeVersion = version.NetbirdVersion()
|
|
gio.UIVersion = extractUserAgent(ctx)
|
|
|
|
return gio
|
|
}
|
|
|
|
// extractOsVersion extracts operating system version from context or returns the default
|
|
func extractOsVersion(ctx context.Context, defaultName string) string {
|
|
v, ok := ctx.Value(OsVersionCtxKey).(string)
|
|
if !ok {
|
|
return defaultName
|
|
}
|
|
return v
|
|
}
|
|
|
|
// extractOsName extracts operating system name from context or returns the default
|
|
func extractOsName(ctx context.Context, defaultName string) string {
|
|
v, ok := ctx.Value(OsNameCtxKey).(string)
|
|
if !ok {
|
|
return defaultName
|
|
}
|
|
return v
|
|
}
|