1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-02-17 09:59:06 +00:00

1. fixed #def issue

2. Added Virtual Machine  detection
This commit is contained in:
Bryan Roe
2020-04-24 16:06:59 -07:00
parent de24ee7543
commit 9682464cb6
4 changed files with 65 additions and 6 deletions

View File

@@ -158,12 +158,14 @@ typedef struct MeshCommand_BinaryPacket_AuthVerify
}MeshCommand_BinaryPacket_AuthVerify;
typedef enum MeshCommand_AuthInfo_PlatformType
{
MeshCommand_AuthInfo_PlatformType_DESKTOP = 1,
MeshCommand_AuthInfo_PlatformType_LAPTOP = 2,
MeshCommand_AuthInfo_PlatformType_MOBILE = 3,
MeshCommand_AuthInfo_PlatformType_SERVER = 4,
MeshCommand_AuthInfo_PlatformType_DISK = 5,
MeshCommand_AuthInfo_PlatformType_ROUTER = 6
MeshCommand_AuthInfo_PlatformType_DESKTOP = 1,
MeshCommand_AuthInfo_PlatformType_LAPTOP = 2,
MeshCommand_AuthInfo_PlatformType_MOBILE = 3,
MeshCommand_AuthInfo_PlatformType_SERVER = 4,
MeshCommand_AuthInfo_PlatformType_DISK = 5,
MeshCommand_AuthInfo_PlatformType_ROUTER = 6,
MeshCommand_AuthInfo_PlatformType_PI = 7,
MeshCommand_AuthInfo_PlatformType_VIRTUAL = 8
}MeshCommand_BinaryPacket_AuthInfo_PlatformType;
typedef struct MeshCommand_BinaryPacket_AuthInfo
{
@@ -2515,6 +2517,20 @@ void MeshServer_SendAgentInfo(MeshAgentHostContainer* agent, ILibWebClient_State
}
}
if (agent->meshCoreCtx != NULL)
{
if (duk_peval_string(agent->meshCoreCtx, "require('identifiers').isVM();") == 0)
{
if (duk_get_boolean(agent->meshCoreCtx, -1))
{
info->platformType = htonl(MeshCommand_AuthInfo_PlatformType_VIRTUAL);
}
}
duk_pop(agent->meshCoreCtx);
}
// Send mesh agent information to the server
ILibWebClient_WebSocket_Send(WebStateObject, ILibWebClient_WebSocket_DataType_BINARY, (char*)info, sizeof(MeshCommand_BinaryPacket_AuthInfo) + hostnamelen, ILibAsyncSocket_MemoryOwnership_USER, ILibWebClient_WebSocket_FragmentFlag_Complete);
agent->retryTime = 0;

View File

@@ -80,6 +80,7 @@ void Duktape_RunOnEventLoop_Sink(void *chain, void *user)
}
ILibMemory_Free(tmp);
}
#ifdef WIN32
void __stdcall Duktape_RunOnEventLoop_SanityCheck(ULONG_PTR u)
{
if (!ILibMemory_CanaryOK((void*)u)) { return; }
@@ -92,6 +93,7 @@ void __stdcall Duktape_RunOnEventLoop_SanityCheck(ULONG_PTR u)
}
}
}
#endif
void Duktape_RunOnEventLoop(void *chain, uintptr_t nonce, duk_context *ctx, Duktape_EventLoopDispatch handler, Duktape_EventLoopDispatch abortHandler, void *user)
{
Duktape_EventLoopDispatchData* tmp = (Duktape_EventLoopDispatchData*)ILibMemory_SmartAllocate(sizeof(Duktape_EventLoopDispatchData));
@@ -103,8 +105,12 @@ void Duktape_RunOnEventLoop(void *chain, uintptr_t nonce, duk_context *ctx, Dukt
tmp->ctxd = duk_ctx_context_data(ctx);
tmp->chain = chain;
#ifdef WIN32
void *tobj = ILibChain_RunOnMicrostackThreadEx3(chain, Duktape_RunOnEventLoop_Sink, Duktape_RunOnEventLoop_AbortSink, tmp);
QueueUserAPC((PAPCFUNC)Duktape_RunOnEventLoop_SanityCheck, ILibChain_GetMicrostackThreadHandle(chain), (ULONG_PTR)tobj);
#else
ILibChain_RunOnMicrostackThreadEx3(chain, Duktape_RunOnEventLoop_Sink, Duktape_RunOnEventLoop_AbortSink, tmp);
#endif
}
int ILibDuktape_GetReferenceCount(duk_context *ctx, duk_idx_t i)

File diff suppressed because one or more lines are too long

View File

@@ -196,6 +196,40 @@ switch(process.platform)
module.exports = { get: function () { throw ('Unsupported Platform'); } };
break;
}
module.exports.isVM = function isVM()
{
var ret = false;
var id = this.get();
if (id.linux && id.linux.sys_vendor)
{
switch(id.linux.sys_vendor)
{
case 'VMware, Inc.':
case 'QEMU':
ret = true;
break;
default:
break;
}
}
if (id.identifiers.bios_vendor && id.identifiers.bios_vendor == 'VMware, Inc.') { ret = true; }
if (id.identifiers.board_vendor && id.identifiers.board_vendor == 'VMware, Inc.') { ret = true; }
if (id.identifiers.board_name)
{
switch(id.identifiers.board_name)
{
case 'VirtualBox':
case 'Virtual Machine':
case 'SeaBIOS':
case 'Xen':
ret = true;
break;
default:
break;
}
}
return (ret);
}
// bios_date = BIOS->ReleaseDate