diff --git a/meshcore/agentcore.c b/meshcore/agentcore.c index 9cc036c..3964735 100644 --- a/meshcore/agentcore.c +++ b/meshcore/agentcore.c @@ -3461,6 +3461,21 @@ void MeshServer_OnResponse(ILibWebClient_StateObject WebStateObject, int Interru strcpy_s(commitPacket + sizeof(uint16_t), sizeof(SOURCE_COMMIT_DATE), SOURCE_COMMIT_DATE); ILibWebClient_WebSocket_Send(WebStateObject, ILibWebClient_WebSocket_DataType_BINARY, (char*)commitPacket, sizeof(commitPacket), ILibAsyncSocket_MemoryOwnership_USER, ILibWebClient_WebSocket_FragmentFlag_Complete); + if (agent->meshCoreCtx != NULL) + { + if (duk_peval_string(agent->meshCoreCtx, "require('os').Name + ' - ' + require('os').arch()") == 0) + { + duk_size_t infoLen; + char *info = (char*)duk_get_lstring(agent->meshCoreCtx, -1, &infoLen); + char *buffer = Duktape_PushBuffer(agent->meshCoreCtx, sizeof(uint16_t) + infoLen); + ((uint16_t*)buffer)[0] = htons(MeshCommand_HostInfo); + memcpy_s(buffer + sizeof(uint16_t), infoLen, info, infoLen); + ILibWebClient_WebSocket_Send(WebStateObject, ILibWebClient_WebSocket_DataType_BINARY, buffer, (int)ILibMemory_Size(buffer), ILibAsyncSocket_MemoryOwnership_USER, ILibWebClient_WebSocket_FragmentFlag_Complete); + duk_pop(agent->meshCoreCtx); + } + duk_pop(agent->meshCoreCtx); + } + #ifndef MICROSTACK_NOTLS X509* peer = ILibWebClient_SslGetCert(WebStateObject); agent->serverAuthState = 0; // We are not authenticated. Bitmask: 1 = Server Auth, 2 = Agent Auth. diff --git a/meshcore/agentcore.h b/meshcore/agentcore.h index b89f4d5..7d26705 100644 --- a/meshcore/agentcore.h +++ b/meshcore/agentcore.h @@ -119,7 +119,9 @@ typedef enum MeshCommands_Binary MeshCommand_AgentUpdate = 13, // Indicate the start and end of the mesh agent binary transfer MeshCommand_AgentUpdateBlock = 14, // Part of the mesh agent sent from the server to the agent, confirmation/flowcontrol from agent to server MeshCommand_AgentTag = 15, // Send the mesh agent tag to the server - MeshCommand_CoreOk = 16 // Sent by the server to indicate the meshcore is ok + MeshCommand_CoreOk = 16, // Sent by the server to indicate the meshcore is ok + MeshCommand_HostInfo = 31, // Host OS and CPU Architecture + } MeshCommands_Binary; #pragma pack(push,1) diff --git a/microscript/ILibDuktapeModSearch.c b/microscript/ILibDuktapeModSearch.c index c826fe0..51c5148 100644 --- a/microscript/ILibDuktapeModSearch.c +++ b/microscript/ILibDuktapeModSearch.c @@ -78,7 +78,6 @@ duk_ret_t ModSearchTable_Put(duk_context *ctx, duk_idx_t table, char *key, char uint32_t ILibDuktape_ModSearch_GetJSModuleDate(duk_context *ctx, char *id) { uint32_t retVal; - ILibHashtable table = NULL; char *mpath; duk_size_t mpathLen; char *fileName = NULL; diff --git a/microscript/ILibDuktape_net.c b/microscript/ILibDuktape_net.c index 9292b40..ca4ffb6 100644 --- a/microscript/ILibDuktape_net.c +++ b/microscript/ILibDuktape_net.c @@ -2268,7 +2268,6 @@ duk_ret_t ILibDuktape_tls_server_addContext(duk_context *ctx) if (duk_has_prop_string(ctx, -1, "ALPNProtocols")) { duk_uarridx_t i; - int status = 0; duk_size_t protoLen = 0; unsigned char *alpn = NULL; duk_get_prop_string(ctx, -1, "ALPNProtocols"); // [server][table][options][Array] @@ -2294,7 +2293,7 @@ duk_ret_t ILibDuktape_tls_server_addContext(duk_context *ctx) protoLen += (unsigned int)bufLen; duk_pop(ctx); // [server][table][options][Array] } - status = SSL_CTX_set_alpn_protos(ssl_ctx, alpn, (unsigned int)protoLen); + SSL_CTX_set_alpn_protos(ssl_ctx, alpn, (unsigned int)protoLen); SSL_CTX_set_alpn_select_cb(ssl_ctx, ILibDuktape_tls_server_alpnSink, Duktape_GetBufferProperty(ctx, -4, ILibDuktape_net_Server_buffer)); } duk_pop(ctx); // [server][table][options] @@ -2346,7 +2345,6 @@ duk_ret_t ILibDuktape_TLS_exportKeys(duk_context *ctx) #endif duk_ret_t ILibDuktape_TLS_connect(duk_context *ctx) { - int status = 0; unsigned char* alpn = NULL; unsigned int protoLen = 0; int nargs = duk_get_top(ctx), i; @@ -2449,7 +2447,7 @@ duk_ret_t ILibDuktape_TLS_connect(duk_context *ctx) protoLen += (unsigned int)bufLen; duk_pop(ctx); // [socket][options][secureContext][Array] } - status = SSL_CTX_set_alpn_protos(data->ssl_ctx, alpn, protoLen); + SSL_CTX_set_alpn_protos(data->ssl_ctx, alpn, protoLen); } duk_pop(ctx); // [socket][options][secureContext] }