2024-10-24 10:53:46 +02:00
|
|
|
package statemanager
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetDefaultStatePath returns the path to the state file based on the operating system
|
2024-11-13 13:46:00 +01:00
|
|
|
// It returns an empty string if the path cannot be determined.
|
2024-10-24 10:53:46 +02:00
|
|
|
func GetDefaultStatePath() string {
|
|
|
|
switch runtime.GOOS {
|
|
|
|
case "windows":
|
2024-11-13 13:46:00 +01:00
|
|
|
return filepath.Join(os.Getenv("PROGRAMDATA"), "Netbird", "state.json")
|
2024-10-24 10:53:46 +02:00
|
|
|
case "darwin", "linux":
|
2024-11-13 13:46:00 +01:00
|
|
|
return "/var/lib/netbird/state.json"
|
2024-10-24 10:53:46 +02:00
|
|
|
case "freebsd", "openbsd", "netbsd", "dragonfly":
|
2024-11-13 13:46:00 +01:00
|
|
|
return "/var/db/netbird/state.json"
|
2024-10-24 10:53:46 +02:00
|
|
|
}
|
|
|
|
|
2024-11-13 13:46:00 +01:00
|
|
|
return ""
|
2024-10-24 10:53:46 +02:00
|
|
|
|
|
|
|
}
|