1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-15 15:53:55 +00:00

1. Added MeshCommand_HostInfo command

2. Fixed compiler warnings
This commit is contained in:
Bryan Roe
2021-08-10 16:41:22 -07:00
parent 75a0ae9817
commit 841642dec4
4 changed files with 20 additions and 6 deletions

View File

@@ -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); 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); 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 #ifndef MICROSTACK_NOTLS
X509* peer = ILibWebClient_SslGetCert(WebStateObject); X509* peer = ILibWebClient_SslGetCert(WebStateObject);
agent->serverAuthState = 0; // We are not authenticated. Bitmask: 1 = Server Auth, 2 = Agent Auth. agent->serverAuthState = 0; // We are not authenticated. Bitmask: 1 = Server Auth, 2 = Agent Auth.

View File

@@ -119,7 +119,9 @@ typedef enum MeshCommands_Binary
MeshCommand_AgentUpdate = 13, // Indicate the start and end of the mesh agent binary transfer 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_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_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; } MeshCommands_Binary;
#pragma pack(push,1) #pragma pack(push,1)

View File

@@ -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 ILibDuktape_ModSearch_GetJSModuleDate(duk_context *ctx, char *id)
{ {
uint32_t retVal; uint32_t retVal;
ILibHashtable table = NULL;
char *mpath; char *mpath;
duk_size_t mpathLen; duk_size_t mpathLen;
char *fileName = NULL; char *fileName = NULL;

View File

@@ -2268,7 +2268,6 @@ duk_ret_t ILibDuktape_tls_server_addContext(duk_context *ctx)
if (duk_has_prop_string(ctx, -1, "ALPNProtocols")) if (duk_has_prop_string(ctx, -1, "ALPNProtocols"))
{ {
duk_uarridx_t i; duk_uarridx_t i;
int status = 0;
duk_size_t protoLen = 0; duk_size_t protoLen = 0;
unsigned char *alpn = NULL; unsigned char *alpn = NULL;
duk_get_prop_string(ctx, -1, "ALPNProtocols"); // [server][table][options][Array] 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; protoLen += (unsigned int)bufLen;
duk_pop(ctx); // [server][table][options][Array] 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)); 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] duk_pop(ctx); // [server][table][options]
@@ -2346,7 +2345,6 @@ duk_ret_t ILibDuktape_TLS_exportKeys(duk_context *ctx)
#endif #endif
duk_ret_t ILibDuktape_TLS_connect(duk_context *ctx) duk_ret_t ILibDuktape_TLS_connect(duk_context *ctx)
{ {
int status = 0;
unsigned char* alpn = NULL; unsigned char* alpn = NULL;
unsigned int protoLen = 0; unsigned int protoLen = 0;
int nargs = duk_get_top(ctx), i; int nargs = duk_get_top(ctx), i;
@@ -2449,7 +2447,7 @@ duk_ret_t ILibDuktape_TLS_connect(duk_context *ctx)
protoLen += (unsigned int)bufLen; protoLen += (unsigned int)bufLen;
duk_pop(ctx); // [socket][options][secureContext][Array] 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] duk_pop(ctx); // [socket][options][secureContext]
} }