mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 15:26:40 +00:00
59 lines
1.5 KiB
Go
59 lines
1.5 KiB
Go
//go:build ios
|
|
// +build ios
|
|
|
|
package system
|
|
|
|
import (
|
|
"context"
|
|
"runtime"
|
|
|
|
"github.com/netbirdio/netbird/client/internal"
|
|
"github.com/netbirdio/netbird/version"
|
|
)
|
|
|
|
// GetInfo retrieves and parses the system information
|
|
func GetInfo(ctx context.Context, config internal.Config) *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,
|
|
RosenpassEnabled: config.RosenpassEnabled,
|
|
RosenpassPermissive: config.RosenpassPermissive,
|
|
}
|
|
if config.ServerSSHAllowed != nil {
|
|
gio.ServerSSHAllowed = true
|
|
}
|
|
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
|
|
}
|