Files
EntitleForge-SDK-go/sdk/fingerprint_darwin.go
T
iceking2nd 834882e044
sdk-ci / test (push) Successful in 1m54s
sdk-release / release (push) Failing after 39s
sdk-release / cleanup (push) Successful in 4s
fix(sdk): 离线 license 默认自动校验机器指纹
- 新增 sdk.MachineFingerprint:Linux machine-id+DMI、macOS IOPlatformUUID,容器内 fail-closed
- 文件模式在 bind.fp 存在时自动校验,无需显式 WithFingerprint;采集失败拒绝绑定 license
- 新增 WithFingerprintFunc 支持容器读取挂载宿主 machine-id;在线激活同步使用自动指纹
- license 包新增 NormalizeFingerprint(sha256:64hex 校验与小写归一化)
- 新增指纹绑定/采集失败/无绑定跳过等测试
2026-11-14 20:02:12 +08:00

27 lines
865 B
Go

//go:build darwin
package sdk
import (
"errors"
"os/exec"
"regexp"
"strings"
)
var ioPlatformUUIDPattern = regexp.MustCompile(`"IOPlatformUUID"\s*=\s*"([^"]+)"`)
// machineFields macOS 采集:IOPlatformUUID(硬件平台 UUID),
// ioreg 不可用时退回 hostname(稳定性较弱,但至少可用于普通拷贝防护)。
func machineFields() ([]string, error) {
if out, err := exec.Command("ioreg", "-rd1", "-c", "IOPlatformExpertDevice").Output(); err == nil {
if m := ioPlatformUUIDPattern.FindStringSubmatch(string(out)); len(m) == 2 && strings.TrimSpace(m[1]) != "" {
return []string{"io-platform-uuid:" + strings.ToLower(strings.TrimSpace(m[1]))}, nil
}
}
if h := hostname(); h != "" && h != "unknown" {
return []string{"hostname:" + h}, nil
}
return nil, errors.New("sdk: macOS 上未取得 IOPlatformUUID 或 hostname")
}