- 新增 sdk.MachineFingerprint:Linux machine-id+DMI、macOS IOPlatformUUID,容器内 fail-closed - 文件模式在 bind.fp 存在时自动校验,无需显式 WithFingerprint;采集失败拒绝绑定 license - 新增 WithFingerprintFunc 支持容器读取挂载宿主 machine-id;在线激活同步使用自动指纹 - license 包新增 NormalizeFingerprint(sha256:64hex 校验与小写归一化) - 新增指纹绑定/采集失败/无绑定跳过等测试
27 lines
865 B
Go
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")
|
|
}
|