diff --git a/client/cmd/login.go b/client/cmd/login.go index c86d6c636..549eef40e 100644 --- a/client/cmd/login.go +++ b/client/cmd/login.go @@ -48,6 +48,9 @@ var loginCmd = &cobra.Command{ return err } + // update host's static platform and system information + system.UpdateStaticInfo() + // workaround to run without service if logFile == "console" { err = handleRebrand(cmd) diff --git a/client/cmd/service_controller.go b/client/cmd/service_controller.go index 0ddf6c4c8..5e3c63e57 100644 --- a/client/cmd/service_controller.go +++ b/client/cmd/service_controller.go @@ -16,12 +16,17 @@ import ( "github.com/netbirdio/netbird/client/proto" "github.com/netbirdio/netbird/client/server" + "github.com/netbirdio/netbird/client/system" "github.com/netbirdio/netbird/util" ) func (p *program) Start(svc service.Service) error { // Start should not block. Do the actual work async. log.Info("starting Netbird service") //nolint + + // Collect static system and platform information + system.UpdateStaticInfo() + // in any case, even if configuration does not exists we run daemon to serve CLI gRPC API. p.serv = grpc.NewServer() diff --git a/client/system/info.go b/client/system/info.go index 2a0343ca6..3a0c57156 100644 --- a/client/system/info.go +++ b/client/system/info.go @@ -185,3 +185,10 @@ func GetInfoWithChecks(ctx context.Context, checks []*proto.Checks) (*Info, erro return info, nil } + +// UpdateStaticInfo asynchronously updates static system and platform information +func UpdateStaticInfo() { + go func() { + _ = updateStaticInfo() + }() +} diff --git a/client/system/static_info.go b/client/system/static_info.go index fabe65a68..f178ec932 100644 --- a/client/system/static_info.go +++ b/client/system/static_info.go @@ -16,12 +16,6 @@ var ( once sync.Once ) -func init() { - go func() { - _ = updateStaticInfo() - }() -} - func updateStaticInfo() StaticInfo { once.Do(func() { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) diff --git a/client/system/static_info_stub.go b/client/system/static_info_stub.go new file mode 100644 index 000000000..faa3e700b --- /dev/null +++ b/client/system/static_info_stub.go @@ -0,0 +1,8 @@ +//go:build android || freebsd || ios + +package system + +// updateStaticInfo returns an empty implementation for unsupported platforms +func updateStaticInfo() StaticInfo { + return StaticInfo{} +}