mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-06 00:13:33 +00:00
Added ability to fetch core hash
This commit is contained in:
@@ -1815,7 +1815,17 @@ duk_ret_t ILibDuktape_MeshAgent_remoteMouseRender_set(duk_context *ctx)
|
||||
gRemoteMouseRenderDefault = duk_require_int(ctx, 0);
|
||||
return(0);
|
||||
}
|
||||
duk_ret_t ILibDuktape_MeshAgent_coreHash(duk_context *ctx)
|
||||
{
|
||||
MeshAgentHostContainer *agent;
|
||||
duk_push_this(ctx); // [MeshAgent]
|
||||
agent = (MeshAgentHostContainer*)Duktape_GetPointerProperty(ctx, -1, MESH_AGENT_PTR);
|
||||
|
||||
char *hashref = ILibSimpleDataStore_GetHash(agent->masterDb, "CoreModule"); // Get the reference to the SHA384 hash for the currently running code
|
||||
util_tohex(hashref, ILibSimpleDataStore_GetHashSize(), ILibScratchPad);
|
||||
duk_push_string(ctx, ILibScratchPad);
|
||||
return(1);
|
||||
}
|
||||
void ILibDuktape_MeshAgent_PUSH(duk_context *ctx, void *chain)
|
||||
{
|
||||
MeshAgentHostContainer *agent;
|
||||
@@ -1888,6 +1898,7 @@ void ILibDuktape_MeshAgent_PUSH(duk_context *ctx, void *chain)
|
||||
ILibDuktape_CreateReadonlyProperty_int(ctx, "activeMicroLMS", (agent->microLMS != NULL ? 1 : 0));
|
||||
ILibDuktape_CreateInstanceMethod(ctx, "restartCore", ILibDuktape_MeshAgent_dumpCoreModule, 0);
|
||||
ILibDuktape_CreateInstanceMethod(ctx, "getStartupOptions", ILibDuktape_MeshAgent_getStartupOptions, 0);
|
||||
ILibDuktape_CreateEventWithGetter(ctx, "coreHash", ILibDuktape_MeshAgent_coreHash);
|
||||
#ifdef _LINKVM
|
||||
ILibDuktape_CreateReadonlyProperty_int(ctx, "hasKVM", 1);
|
||||
ILibDuktape_EventEmitter_CreateEventEx(emitter, "kvmConnected");
|
||||
|
||||
@@ -702,7 +702,11 @@ __EXPORT_TYPE char* ILibSimpleDataStore_GetHashEx(ILibSimpleDataStore dataStore,
|
||||
if (entry == NULL) return NULL; // If there is no in-memory entry for this key, return zero now.
|
||||
return entry->valueHash;
|
||||
}
|
||||
|
||||
int ILibSimpleDataStore_GetHashSize()
|
||||
{
|
||||
ILibSimpleDataStore_TableEntry e;
|
||||
return((int)sizeof(e.valueHash));
|
||||
}
|
||||
// Delete a key and value from the data store
|
||||
__EXPORT_TYPE int ILibSimpleDataStore_DeleteEx(ILibSimpleDataStore dataStore, char* key, int keyLen)
|
||||
{
|
||||
|
||||
@@ -66,9 +66,10 @@ __EXPORT_TYPE int ILibSimpleDataStore_GetEx(ILibSimpleDataStore dataStore, char*
|
||||
#define ILibSimpleDataStore_Get(dataStore, key, buffer, bufferLen) ILibSimpleDataStore_GetEx(dataStore, key, (int)strnlen_s(key, ILibSimpleDataStore_MaxKeyLength), buffer, bufferLen)
|
||||
__EXPORT_TYPE int ILibSimpleDataStore_GetInt(ILibSimpleDataStore dataStore, char* key, int defaultValue);
|
||||
|
||||
// Get the SHA256 hash value from the datastore for a given a key.
|
||||
// Get the SHA384 hash value from the datastore for a given a key.
|
||||
__EXPORT_TYPE char* ILibSimpleDataStore_GetHashEx(ILibSimpleDataStore dataStore, char* key, int keyLen);
|
||||
#define ILibSimpleDataStore_GetHash(dataStore, key) ILibSimpleDataStore_GetHashEx(dataStore, key, (int)strnlen_s(key, ILibSimpleDataStore_MaxKeyLength))
|
||||
int ILibSimpleDataStore_GetHashSize();
|
||||
|
||||
// Delete a key from the data store
|
||||
__EXPORT_TYPE int ILibSimpleDataStore_DeleteEx(ILibSimpleDataStore dataStore, char* key, int keyLen);
|
||||
|
||||
Reference in New Issue
Block a user