mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-06 00:13:33 +00:00
Added '-nodeid' command switch, to display Agent Node ID
This commit is contained in:
@@ -122,7 +122,12 @@ char* crashMemory = ILib_POSIX_InstallCrashHandler(argv[0]);
|
|||||||
integratedJavaScript = ILibString_Copy(argv[2], -1);
|
integratedJavaScript = ILibString_Copy(argv[2], -1);
|
||||||
integratedJavaScriptLen = (int)strnlen_s(integratedJavaScript, sizeof(ILibScratchPad));
|
integratedJavaScriptLen = (int)strnlen_s(integratedJavaScript, sizeof(ILibScratchPad));
|
||||||
}
|
}
|
||||||
|
if (argc > 1 && strcasecmp(argv[1], "-nodeid") == 0)
|
||||||
|
{
|
||||||
|
char script[] = "console.log(require('_agentNodeId')());process.exit();";
|
||||||
|
integratedJavaScript = ILibString_Copy(script, (int)sizeof(script) - 1);
|
||||||
|
integratedJavaScriptLen = (int)sizeof(script) - 1;
|
||||||
|
}
|
||||||
if (argc > 1 && strcasecmp(argv[1], "-info") == 0)
|
if (argc > 1 && strcasecmp(argv[1], "-info") == 0)
|
||||||
{
|
{
|
||||||
printf("Compiled on: %s, %s\n", __TIME__, __DATE__);
|
printf("Compiled on: %s, %s\n", __TIME__, __DATE__);
|
||||||
|
|||||||
@@ -948,7 +948,12 @@ int main(int argc, char* argv[])
|
|||||||
integratedJavaScript = ILibString_Copy(argv[2], -1);
|
integratedJavaScript = ILibString_Copy(argv[2], -1);
|
||||||
integragedJavaScriptLen = (int)strnlen_s(integratedJavaScript, sizeof(ILibScratchPad));
|
integragedJavaScriptLen = (int)strnlen_s(integratedJavaScript, sizeof(ILibScratchPad));
|
||||||
}
|
}
|
||||||
|
if (argc > 1 && strcasecmp(argv[1], "-nodeid") == 0)
|
||||||
|
{
|
||||||
|
char script[] = "console.log(require('_agentNodeId')());process.exit();";
|
||||||
|
integratedJavaScript = ILibString_Copy(script, (int)sizeof(script) - 1);
|
||||||
|
integragedJavaScriptLen = (int)sizeof(script) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
50
modules/_agentNodeId.js
Normal file
50
modules/_agentNodeId.js
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2019 Intel Corporation
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function _meshNodeId()
|
||||||
|
{
|
||||||
|
var ret = '';
|
||||||
|
switch (process.platform)
|
||||||
|
{
|
||||||
|
case 'linux':
|
||||||
|
case 'darwin':
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var db = require('SimpleDataStore').Create(process.execPath + '.db', { readOnly: true });
|
||||||
|
ret = require('tls').loadCertificate({ pfx: db.GetBuffer('SelfNodeCert'), passphrase: 'hidden' }).getKeyHash().toString('hex');
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'win32':
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var reg = require('win-registry');
|
||||||
|
ret = Buffer.from(reg.QueryKey(reg.HKEY.LocalMachine, 'Software\\Open Source\\MeshAgent2', 'NodeId').toString(), 'base64').toString('hex');
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = _meshNodeId;
|
||||||
|
|
||||||
Reference in New Issue
Block a user