-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* machine data is now being registered. and a fingerprint is calculated using the registered data * api version added
- Loading branch information
Showing
5 changed files
with
232 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const config = require('config') | ||
const { v5: uuidv5, v4: uuidv4 } = require('uuid') | ||
|
||
const NAMESPACE = uuidv5(config.system.secret, config.system.secret_uuid) | ||
|
||
module.exports = (machineData) => { | ||
const payload = [] | ||
for (let name in machineData) { | ||
const part = machineData[name] | ||
if (typeof part === 'string') { | ||
payload.push(part) | ||
} else if (name === 'cpu' || name === 'net') { | ||
// an array of available cpu/net | ||
if (Array.isArray(part)) { | ||
for (let idx = 0; idx < part.length; idx++) { | ||
const device = part[idx] | ||
if (name === 'cpu') { | ||
payload.push(device.model) | ||
// array of model, speed | ||
} | ||
else if (name === 'net') { | ||
// array of name, address, mac | ||
payload.push(device.name + device.addres + device.mac) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
payload.sort() | ||
const fingerprint = Buffer.from(payload.join('')).toString('base64') | ||
return uuidv5(fingerprint, NAMESPACE) | ||
} |
Oops, something went wrong.