mirror of
https://github.com/Ylianst/MeshAgent
synced 2026-02-06 19:53:14 +00:00
Added capability, such that if 'agentName' is specified in the db/msh, it will override the hostname sent to the server
This commit is contained in:
@@ -2501,7 +2501,8 @@ void MeshServer_ServerAuthenticated(ILibWebClient_StateObject WebStateObject, Me
|
||||
}
|
||||
}
|
||||
|
||||
void MeshServer_SendAgentInfo(MeshAgentHostContainer* agent, ILibWebClient_StateObject WebStateObject) {
|
||||
void MeshServer_SendAgentInfo(MeshAgentHostContainer* agent, ILibWebClient_StateObject WebStateObject)
|
||||
{
|
||||
int hostnamelen = (int)strnlen_s(agent->hostname, sizeof(agent->hostname));
|
||||
|
||||
// Send to the server information about this agent
|
||||
@@ -2514,8 +2515,16 @@ void MeshServer_SendAgentInfo(MeshAgentHostContainer* agent, ILibWebClient_State
|
||||
info->platformType = htonl(((agent->batteryState != MeshAgentHost_BatteryInfo_NONE) && (agent->batteryState != MeshAgentHost_BatteryInfo_UNKNOWN)) ? MeshCommand_AuthInfo_PlatformType_LAPTOP : MeshCommand_AuthInfo_PlatformType_DESKTOP);
|
||||
memcpy_s(info->MeshID, sizeof(info->MeshID), agent->meshId, sizeof(agent->meshId));
|
||||
info->capabilities = htonl(agent->capabilities);
|
||||
info->hostnameLen = htons(hostnamelen);
|
||||
memcpy_s(info->hostname, sizeof(ILibScratchPad2) - sizeof(MeshCommand_BinaryPacket_AuthInfo), agent->hostname, hostnamelen);
|
||||
|
||||
if ((info->hostnameLen = htons(ILibSimpleDataStore_Get(agent->masterDb, "agentName", info->hostname, sizeof(ILibScratchPad2) - sizeof(info)))) == 0)
|
||||
{
|
||||
info->hostnameLen = htons(hostnamelen);
|
||||
memcpy_s(info->hostname, sizeof(ILibScratchPad2) - sizeof(MeshCommand_BinaryPacket_AuthInfo), agent->hostname, hostnamelen);
|
||||
}
|
||||
else
|
||||
{
|
||||
hostnamelen = ntohs(info->hostnameLen) - 1;
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -233,6 +233,7 @@ char* MeshAgent_MakeAbsolutePath(char *basePath, char *localPath);
|
||||
*
|
||||
*
|
||||
AgentCapabilities: Integer Mask, specifying supported Agent Capabilities
|
||||
agentName If set, this will be sent to the server instead of the hostname
|
||||
controlChannelDebug: If set, will log/display controlChannel messages (Except for JSON messages)
|
||||
controlChannelIdleTimeout: Integer value specifying the idle timeout in seconds, to send Ping/Pong to server, to keep connection alive
|
||||
coreDumpEnabled: If set, a dump file will be written when the agent crashes
|
||||
|
||||
Reference in New Issue
Block a user