1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-24 12:13:16 +00:00

Updated, so windows will save NodeID to db

This commit is contained in:
Bryan Roe
2019-04-08 15:42:08 -07:00
parent d457364197
commit a5000eee85
3 changed files with 66 additions and 29 deletions

View File

@@ -31,12 +31,21 @@ function _meshNodeId()
}
break;
case 'win32':
// First Check if the db Contains the NodeID
try
{
var reg = require('win-registry');
ret = Buffer.from(reg.QueryKey(reg.HKEY.LocalMachine, 'Software\\Open Source\\MeshAgent2', 'NodeId').toString(), 'base64').toString('hex');
var db = require('SimpleDataStore').Create(process.execPath.replace('.exe', '.db'), { readOnly: true });
var v = db.GetBuffer('NodeID');
if(v!=null)
{
ret = v.toString('hex');
}
else
{
ret = require('tls').loadCertificate({ pfx: db.GetBuffer('SelfNodeCert'), passphrase: 'hidden' }).getKeyHash().toString('hex');
}
}
catch(e)
catch (e)
{
}
break;