mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-06 00:13:33 +00:00
Updated metadata
This commit is contained in:
@@ -3162,6 +3162,7 @@ void MeshServer_ControlChannel_PongSink(ILibWebClient_StateObject WebStateObject
|
||||
void MeshServer_OnResponse(ILibWebClient_StateObject WebStateObject, int InterruptFlag, struct packetheader *header, char *bodyBuffer, int *beginPointer, int endPointer, ILibWebClient_ReceiveStatus recvStatus, void *user1, void *user2, int *PAUSE)
|
||||
{
|
||||
MeshAgentHostContainer *agent = (MeshAgentHostContainer*)user1;
|
||||
ILibChain_Link_SetMetadata(ILibChain_GetCurrentLink(agent->chain), "MeshServer_ControlChannel");
|
||||
|
||||
// Look at the various connection states and handle data if needed
|
||||
switch (recvStatus)
|
||||
|
||||
@@ -35,6 +35,7 @@ typedef void(*ILibDuktape_HelperEvent)(duk_context *ctx, void *user);
|
||||
#define ILibDuktape_CR2HTTP "\xFF_CR2HTTP"
|
||||
#define ILibDuktape_CR2Options "\xFF_CR2Options"
|
||||
#define ILibDuktape_TLS_util_cert "\xFF_TLS_util_cert"
|
||||
#define ILibDuktape_ChainLinkPtr "\xFF_Duktape_ChainLink"
|
||||
|
||||
typedef enum ILibDuktape_LogTypes
|
||||
{
|
||||
|
||||
@@ -498,7 +498,9 @@ duk_ret_t ILibDuktape_HttpStream_http_onUpgrade(duk_context *ctx)
|
||||
duk_pop(ctx); // ...
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ILibChain_Link_SetMetadata(Duktape_GetPointerProperty(ctx, -2, ILibDuktape_ChainLinkPtr), Duktape_GetStringPropertyValue(ctx, -1, ILibDuktape_OBJID, "http.webSocketStream"));
|
||||
|
||||
duk_get_prop_string(ctx, -3, ILibDuktape_HTTP2CR); // [HTTPStream][readable][websocket][clientRequest]
|
||||
//duk_dup(ctx, -2); // [HTTPStream][readable][websocket][clientRequest][websocket]
|
||||
//duk_put_prop_string(ctx, -2, ILibDuktape_CR2WS); // [HTTPStream][readable][websocket][clientRequest]
|
||||
@@ -729,8 +731,8 @@ duk_ret_t ILibDuktape_HttpStream_http_OnSocketReady(duk_context *ctx)
|
||||
duk_call_method(ctx, 1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ILibChain_Link_SetMetadata(Duktape_GetPointerProperty(ctx, -2, ILibDuktape_ChainLinkPtr), Duktape_GetStringPropertyValue(ctx, -1, ILibDuktape_OBJID, "http.clientRequest"));
|
||||
|
||||
// Register ourselves for the close event, becuase we'll need to put ourselves back in the Queue if the socket dies before we are done
|
||||
duk_get_prop_string(ctx, -2, "prependOnceListener"); // [socket][clientRequest][prependOnce]
|
||||
@@ -4198,6 +4200,40 @@ duk_ret_t ILibDuktape_httpStream_webSocket_exportKeys(duk_context *ctx)
|
||||
return(ILibDuktape_Error(ctx, "Error exporting keys"));
|
||||
}
|
||||
#endif
|
||||
void ILibDuktape_httpStream_webSocketStream_descriptorMetadataEx(duk_context *ctx, void ** args, int argsLen)
|
||||
{
|
||||
ILibDuktape_WebSocket_State *ws = (ILibDuktape_WebSocket_State*)args[0];
|
||||
char *str = (char*)args[1];
|
||||
|
||||
if(ws->encodedStream->writableStream->pipedReadable != NULL)
|
||||
{
|
||||
duk_push_heapptr(ctx, ws->encodedStream->writableStream->pipedReadable); // [WebSocket_Decoded][WebSocket][Readable]
|
||||
char * tmp = (char*)duk_push_sprintf(ctx, "%s, %s", ILibChain_Link_GetMetadata(Duktape_GetPointerProperty(ctx, -1, ILibDuktape_ChainLinkPtr)), str);
|
||||
char *tmp2 = ILibMemory_SmartAllocate(duk_get_length(ctx, -1) + 1); // [WebSocket_Decoded][WebSocket][Readable][str]
|
||||
memcpy_s(tmp2, ILibMemory_Size(tmp2), tmp, ILibMemory_Size(tmp2) - 1);
|
||||
ILibChain_Link_SetMetadata(Duktape_GetPointerProperty(ctx, -2, ILibDuktape_ChainLinkPtr), tmp2);
|
||||
}
|
||||
}
|
||||
|
||||
duk_ret_t ILibDuktape_httpStream_webSocketStream_descriptorMetadata(duk_context *ctx)
|
||||
{
|
||||
ILibDuktape_WebSocket_State *ws = NULL;
|
||||
duk_push_this(ctx); // [WebSocket_Decoded]
|
||||
duk_get_prop_string(ctx, -1, ILibDuktape_WSDEC2WS); // [WebSocket_Decoded][WebSocket]
|
||||
ws = (ILibDuktape_WritableStream*)Duktape_GetBufferProperty(ctx, -1, ILibDuktape_WebSocket_StatePtr);
|
||||
if (ws != NULL)
|
||||
{
|
||||
if (ws->encodedStream->writableStream->pipedReadable == NULL)
|
||||
{
|
||||
ILibDuktape_Immediate(ctx, (void *[]) { ws, duk_require_string(ctx, 0) }, 2, ILibDuktape_httpStream_webSocketStream_descriptorMetadataEx);
|
||||
}
|
||||
else
|
||||
{
|
||||
ILibDuktape_httpStream_webSocketStream_descriptorMetadataEx(ctx, (void *[]) { ws, duk_require_string(ctx, 0) }, 2);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
duk_ret_t ILibDuktape_httpStream_webSocketStream_new(duk_context *ctx)
|
||||
{
|
||||
ILibDuktape_WebSocket_State *state;
|
||||
@@ -4233,9 +4269,9 @@ duk_ret_t ILibDuktape_httpStream_webSocketStream_new(duk_context *ctx)
|
||||
ILibDuktape_CreateInstanceMethod(ctx, "_exportKeys", ILibDuktape_httpStream_webSocket_exportKeys, 0);
|
||||
#endif
|
||||
|
||||
ILibDuktape_CreateEventWithSetterEx(ctx, "descriptorMetadata", ILibDuktape_httpStream_webSocketStream_descriptorMetadata);
|
||||
ILibDuktape_CreateReadonlyProperty(ctx, "decoded"); // [WebSocket]
|
||||
ILibDuktape_CreateFinalizer(ctx, ILibDuktape_httpStream_webSocketStream_finalizer);
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -618,6 +618,8 @@ void ILibDuktape_net_socket_PUSH(duk_context *ctx, ILibAsyncSocket_SocketModule
|
||||
ptrs->chain = ((ILibChain_Link*)module)->ParentChain;
|
||||
ptrs->object = duk_get_heapptr(ctx, -1);
|
||||
ptrs->socketModule = module;
|
||||
ILibChain_Link_SetMetadata(module, "net.socket");
|
||||
duk_push_pointer(ctx, ptrs->socketModule); duk_put_prop_string(ctx, -2, ILibDuktape_ChainLinkPtr);
|
||||
|
||||
duk_push_pointer(ctx, ptrs); // [obj][ptrs]
|
||||
duk_put_prop_string(ctx, -2, ILibDuktape_net_socket_ptr); // [obj]
|
||||
@@ -1892,6 +1894,7 @@ duk_ret_t ILibDuktape_TLS_connect(duk_context *ctx)
|
||||
|
||||
ILibDuktape_net_socket_PUSH(ctx, module); // [socket]
|
||||
ILibDuktape_WriteID(ctx, "tls.socket");
|
||||
ILibChain_Link_SetMetadata(module, "tls.socket")
|
||||
#ifdef _SSL_KEYS_EXPORTABLE
|
||||
ILibDuktape_CreateInstanceMethod(ctx, "_exportKeys", ILibDuktape_TLS_exportKeys, 0);
|
||||
#endif
|
||||
|
||||
@@ -1796,6 +1796,7 @@ void ILibChain_SafeRemoveEx(void *chain, void *object)
|
||||
if (link != NULL)
|
||||
{
|
||||
if (link->DestroyHandler != NULL) { link->DestroyHandler(link); }
|
||||
ILibMemory_Free(link->MetaData);
|
||||
ILibChain_FreeLink(link);
|
||||
ILibLinkedList_Remove(node);
|
||||
}
|
||||
@@ -1910,7 +1911,12 @@ void* ILibGetBaseTimer(void *chain)
|
||||
//return ILibCreateLifeTime(chain);
|
||||
return (chain == NULL ? NULL : ((struct ILibBaseChain*)chain)->Timer);
|
||||
}
|
||||
|
||||
ILibChain_Link* ILibChain_GetCurrentLink(void *chain)
|
||||
{
|
||||
if (chain == NULL) { return(NULL); }
|
||||
if (((ILibBaseChain*)chain)->node == NULL) { return(NULL); }
|
||||
return((ILibChain_Link*)ILibLinkedList_GetDataFromNode(((ILibBaseChain*)chain)->node));
|
||||
}
|
||||
#ifdef WIN32
|
||||
void __stdcall ILibForceUnBlockChain_APC(ULONG_PTR obj)
|
||||
{
|
||||
@@ -1959,6 +1965,7 @@ void ILibChain_DestroyEx(void *subChain)
|
||||
while (node != NULL && (module = (ILibChain_Link*)ILibLinkedList_GetDataFromNode(node)) != NULL)
|
||||
{
|
||||
if (module->DestroyHandler != NULL) { module->DestroyHandler((void*)module); }
|
||||
ILibMemory_Free(module->MetaData);
|
||||
ILibChain_FreeLink(module);
|
||||
node = ILibLinkedList_GetNextNode(node);
|
||||
}
|
||||
@@ -2303,6 +2310,7 @@ ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules,
|
||||
if (module != NULL)
|
||||
{
|
||||
if (module->DestroyHandler != NULL) { module->DestroyHandler((void*)module); }
|
||||
ILibMemory_Free(module->MetaData);
|
||||
ILibChain_FreeLink(module);
|
||||
}
|
||||
}
|
||||
@@ -3563,6 +3571,7 @@ ILibExportMethod void ILibStartChain(void *Chain)
|
||||
if (module != NULL)
|
||||
{
|
||||
if (module->DestroyHandler != NULL) { module->DestroyHandler((void*)module); }
|
||||
ILibMemory_Free(module->MetaData);
|
||||
ILibChain_FreeLink(module);
|
||||
}
|
||||
}
|
||||
@@ -3703,6 +3712,7 @@ ILibExportMethod void ILibStartChain(void *Chain)
|
||||
// If this module has a destroy method, call it.
|
||||
//
|
||||
if (module->DestroyHandler != NULL) module->DestroyHandler((void*)module);
|
||||
ILibMemory_Free(module->MetaData);
|
||||
//
|
||||
// After calling the Destroy, we free the module and move to the next
|
||||
//
|
||||
@@ -3730,6 +3740,7 @@ ILibExportMethod void ILibStartChain(void *Chain)
|
||||
if (chain->node!=NULL && (module=(ILibChain_Link*)ILibLinkedList_GetDataFromNode(chain->node))!=NULL)
|
||||
{
|
||||
module->DestroyHandler((void*)module);
|
||||
ILibMemory_Free(module->MetaData);
|
||||
ILibChain_FreeLink(module);
|
||||
((ILibBaseChain*)Chain)->Timer = NULL;
|
||||
}
|
||||
@@ -3740,6 +3751,7 @@ ILibExportMethod void ILibStartChain(void *Chain)
|
||||
while(chain->node != NULL && (module = (ILibChain_Link*)ILibLinkedList_GetDataFromNode(chain->node)) != NULL)
|
||||
{
|
||||
if(module->DestroyHandler != NULL) {module->DestroyHandler((void*)module);}
|
||||
ILibMemory_Free(module->MetaData);
|
||||
ILibChain_FreeLink(module);
|
||||
chain->node = ILibLinkedList_GetNextNode(chain->node);
|
||||
}
|
||||
|
||||
@@ -388,6 +388,8 @@ int ILibIsRunningOnChainThread(void* chain);
|
||||
ILibMemory_Types memoryType;
|
||||
}ILibMemory_Header;
|
||||
|
||||
#define ILibChain_Link_SetMetadata(chainLink, value) if((chainLink)!=NULL) { ILibMemory_Free(((ILibChain_Link*)chainLink)->MetaData); ((ILibChain_Link*)chainLink)->MetaData = value; }
|
||||
#define ILibChain_Link_GetMetadata(chainLink) ((chainLink)==NULL?"":(((ILibChain_Link*)chainLink)->MetaData))
|
||||
#define ILibMemory_Canary (((int*)((char*)(const char*)"broe"))[0])
|
||||
#define ILibMemory_RawPtr(ptr) ((char*)(ptr) - sizeof(ILibMemory_Header))
|
||||
#define ILibMemory_RawSize(ptr) (ILibMemory_Size((ptr)) + ILibMemory_ExtraSize((ptr)) + sizeof(ILibMemory_Header))
|
||||
@@ -971,6 +973,7 @@ int ILibIsRunningOnChainThread(void* chain);
|
||||
void ILibChain_SafeRemoveEx(void *chain, void *object);
|
||||
void ILibChain_DestroyEx(void *chain);
|
||||
void ILibChain_DisableWatchDog(void *chain);
|
||||
ILibChain_Link* ILibChain_GetCurrentLink(void *chain);
|
||||
void *ILibChain_GetObjectForDescriptor(void *chain, int fd);
|
||||
char *ILibChain_GetMetaDataFromDescriptorSet(void *chain, fd_set *inr, fd_set *inw, fd_set *ine);
|
||||
char *ILibChain_GetMetaDataFromDescriptorSetEx(void *chain, fd_set *inr, fd_set *inw, fd_set *ine);
|
||||
|
||||
@@ -6377,9 +6377,11 @@ void* ILibStunClient_Start(void *Chain, unsigned short LocalPort, ILibStunClient
|
||||
obj->ChainLink.DestroyHandler = &ILibStun_OnDestroy;
|
||||
obj->UDP = ILibAsyncUDPSocket_CreateEx(Chain, ILibRUDP_MaxMTU, (struct sockaddr*)&(obj->LocalIf), ILibAsyncUDPSocket_Reuse_EXCLUSIVE, &ILibStun_OnUDP, NULL, obj);
|
||||
if (obj->UDP == NULL) { free(obj); return NULL; }
|
||||
ILibChain_Link_SetMetadata(obj->UDP, "ILibWebRTC_stun_listener_ipv4");
|
||||
#ifdef WIN32
|
||||
obj->UDP6 = ILibAsyncUDPSocket_CreateEx(Chain, ILibRUDP_MaxMTU, (struct sockaddr*)&(obj->LocalIf6), ILibAsyncUDPSocket_Reuse_EXCLUSIVE, &ILibStun_OnUDP, NULL, obj);
|
||||
if (obj->UDP6 == NULL) { free(obj); return NULL; }
|
||||
ILibChain_Link_SetMetadata(obj->UDP6, "ILibWebRTC_stun_listener_ipv6");
|
||||
#endif
|
||||
|
||||
ILibAddToChain(Chain, obj);
|
||||
|
||||
Reference in New Issue
Block a user