feat: agent metadata with custom collectors
This commit is contained in:
29
internal/machineid/get.go
Normal file
29
internal/machineid/get.go
Normal file
@ -0,0 +1,29 @@
|
||||
package machineid
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btcd/btcutil/base58"
|
||||
"github.com/denisbrodbeck/machineid"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const salt = "emissary.cadoles.com"
|
||||
|
||||
func Get() (string, error) {
|
||||
machineID, err := getProtectedMachineID()
|
||||
if err != nil {
|
||||
return "", errors.WithStack(err)
|
||||
}
|
||||
|
||||
return machineID, nil
|
||||
}
|
||||
|
||||
func getProtectedMachineID() (string, error) {
|
||||
id, err := machineid.ProtectedID(salt)
|
||||
if err != nil {
|
||||
return "", errors.WithStack(err)
|
||||
}
|
||||
|
||||
encoded := base58.Encode([]byte(id))
|
||||
|
||||
return encoded, nil
|
||||
}
|
Reference in New Issue
Block a user