Documentation
¶
Overview ¶
Package machineid provides support for reading the unique machine id of most OSs (without admin privileges).
https://github.com/darkit/machineid
https://godoc.org/github.com/darkit/machineid/cmd/machineid
This package is Cross-Platform (tested on Win7+, Debian 8+, Ubuntu 14.04+, OS X 10.6+, FreeBSD 11+) and does not use any internal hardware IDs (no MAC, BIOS, or CPU).
Returned machine IDs are generally stable for the OS installation and usually stay the same after updates or hardware changes.
This package allows sharing of machine IDs in a secure way by calculating HMAC-SHA256 over a user provided app ID, which is keyed by the machine id.
Caveat: Image-based environments have usually the same machine-id (perfect clone). Linux users can generate a new id with `dbus-uuidgen` and put the id into `/var/lib/dbus/machine-id` and `/etc/machine-id`. Windows users can use the `sysprep` toolchain to create images, which produce valid images ready for distribution.
Index ¶
- Constants
- func ClearCache()
- func ClearHardwareCache()
- func GetHardwareFingerprint() (string, error)
- func GetHardwareInfo() (*linuxHardwareInfo, error)
- func GetMACAddress() (string, error)
- func ID() (string, error)
- func IsContainer() bool
- func ProtectedID(appID string) (string, error)
- func ProtectedIDWithHardware(appID string) (string, error)
- func ProtectedIDWithMAC(appID string) (string, error)
- type BindingMode
- type BindingResult
- type FingerprintStatus
- type HardwareWeight
- type Info
- type MACInfo
Constants ¶
const (
// the environment variable name pointing to the machine id pathname
ENV_VARNAME = "MACHINE_ID_FILE"
)
Variables ¶
This section is empty.
Functions ¶
func GetHardwareFingerprint ¶ added in v1.0.6
GetHardwareFingerprint 生成硬件指纹
func GetHardwareInfo ¶ added in v1.0.6
func GetHardwareInfo() (*linuxHardwareInfo, error)
GetHardwareInfo 获取详细硬件信息
func GetMACAddress ¶ added in v1.0.6
GetMACAddress 获取主网卡的MAC地址,提供给用户直接使用
func ID ¶
ID returns the platform specific machine id of the current host OS. Regard the returned id as "confidential" and consider using ProtectedID() instead.
func ProtectedID ¶
ProtectedID returns a hashed version of the machine ID in a cryptographically secure way, using intelligent priority-based hardware binding when available.
Priority order: 1. Hardware fingerprint (most stable) 2. MAC address binding (fallback) 3. Pure machine ID (basic)
func ProtectedIDWithHardware ¶ added in v1.0.6
ProtectedIDWithHardware 基于硬件指纹的保护ID
func ProtectedIDWithMAC ¶ added in v1.0.6
ProtectedIDWithMAC returns a hashed version of the machine ID bound to MAC address. Deprecated: Use ProtectedID instead, which intelligently handles hardware binding.
Types ¶
type BindingMode ¶ added in v1.0.7
type BindingMode string
BindingMode 表示保护ID最终采用的绑定模式
const ( BindingModeFingerprint BindingMode = "fingerprint" BindingModeMAC BindingMode = "mac" BindingModeMachineID BindingMode = "machine_id" )
type BindingResult ¶ added in v1.0.7
type BindingResult struct {
Hash string
Mode BindingMode
FingerprintError error
MACError error
}
BindingResult 描述生成保护ID时采用的模式与降级原因
func ProtectedIDResult ¶ added in v1.0.7
func ProtectedIDResult(appID string) (*BindingResult, error)
ProtectedIDResult 返回包含详细绑定信息的结果
func ProtectedIDWithMACResult ¶ added in v1.0.7
func ProtectedIDWithMACResult(appID string) (*BindingResult, error)
ProtectedIDWithMACResult 返回强制 MAC 绑定模式下的详细结果
type FingerprintStatus ¶ added in v1.0.7
FingerprintStatus 描述硬件指纹的值与稳定性
func GetHardwareFingerprintStatus ¶ added in v1.0.7
func GetHardwareFingerprintStatus() (*FingerprintStatus, error)
GetHardwareFingerprintStatus 返回指纹值及稳定性
type HardwareWeight ¶ added in v1.0.6
HardwareWeight 硬件信息权重
type Info ¶ added in v1.0.6
type Info struct {
MachineID string `json:"machine_id"` // 原始机器码
ProtectedID string `json:"protected_id"` // 应用保护机器码
MACAddress string `json:"mac_address,omitempty"` // MAC地址(可选硬件绑定)
IsContainer bool `json:"is_container"` // 是否容器环境
ContainerID string `json:"container_id,omitempty"` // 容器ID
}
Info 返回系统信息摘要
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cert 提供证书管理功能,包括证书的签发、验证和吊销管理。
|
Package cert 提供证书管理功能,包括证书的签发、验证和吊销管理。 |
|
cmd
|
|
|
authorize
command
|
|
|
hardware
command
|
|
|
machineid
command
Package main provides the command line app for reading the unique machine id of most OSs.
|
Package main provides the command line app for reading the unique machine id of most OSs. |
