mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 07:16:38 +00:00
This PR refactors the system information collection code by moving static system information gathering to a dedicated location and separating platform-specific implementations. The primary goal is to improve code organization and maintainability by centralizing static info collection logic. Key changes: - Centralized static info collection into dedicated files with platform-specific implementations - Moved `StaticInfo` struct definition to the main static_info.go file - Added async initialization function `UpdateStaticInfoAsync()` across all platforms
36 lines
709 B
Go
36 lines
709 B
Go
//go:build (linux && !android) || (darwin && !ios)
|
|
|
|
package system
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
"time"
|
|
|
|
"github.com/netbirdio/netbird/client/system/detect_cloud"
|
|
"github.com/netbirdio/netbird/client/system/detect_platform"
|
|
)
|
|
|
|
func newStaticInfo() StaticInfo {
|
|
si := StaticInfo{}
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
defer cancel()
|
|
wg := sync.WaitGroup{}
|
|
wg.Add(3)
|
|
go func() {
|
|
si.SystemSerialNumber, si.SystemProductName, si.SystemManufacturer = sysInfo()
|
|
wg.Done()
|
|
}()
|
|
go func() {
|
|
si.Environment.Cloud = detect_cloud.Detect(ctx)
|
|
wg.Done()
|
|
}()
|
|
go func() {
|
|
si.Environment.Platform = detect_platform.Detect(ctx)
|
|
wg.Done()
|
|
}()
|
|
wg.Wait()
|
|
return si
|
|
}
|