yao/commercial/machine_linux.go
Max 6e003875b4 feat(licenses): implement machine ID binding for license validation
- Added support for machine ID binding in license certificates, ensuring that if a machine ID is specified, it must match the current runtime machine ID for the license to be valid.
- Introduced new tests to verify behavior for empty, matching, and mismatching machine IDs in certificates, enhancing the robustness of license validation.
- Updated LicenseInfo struct to include MachineID field, reflecting the new binding requirement.
2026-03-27 17:18:17 +08:00

23 lines
354 B
Go

//go:build linux
package commercial
import (
"os"
"strings"
)
func platformMachineID() string {
data, err := os.ReadFile("/etc/machine-id")
if err != nil {
data, err = os.ReadFile("/var/lib/dbus/machine-id")
if err != nil {
return ""
}
}
id := strings.TrimSpace(strings.ToLower(string(data)))
if id == "" {
return ""
}
return id
}