Skip to content

Commit

Permalink
removes double register for some agents via sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Updyke committed Mar 22, 2024
1 parent 5b63f73 commit 750f4aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/Ghosts.Api/Hubs/ClientHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ public async Task SendTimeline(string message)

public async Task SendHeartbeat(string message)
{
var m = await FindMachine();
_log.Trace($"{m.Name} {m.Id} ({Context.ConnectionId}) - ReceiveHeartbeat");
var m = GetMachine();

_log.Trace(m.Id != Guid.Empty
? $"{m.Name} {m.Id} ({Context.ConnectionId}) - ReceiveHeartbeat"
: $"New machine — ({Context.ConnectionId}) - ReceiveHeartbeat");
await Clients.Caller.SendAsync("ReceiveHeartbeat", DateTime.UtcNow, this._ct);
}

Expand All @@ -144,10 +147,16 @@ public async Task SendSpecificMessage(string message)
await Clients.Caller.SendAsync("ReceiveSpecificMessage", message, this._ct);
}

private async Task<Machine> FindMachine()
private Machine GetMachine()
{
var machineResponse = new FindMachineResponse();
var m = WebRequestReader.GetMachine(Context.GetHttpContext());
return m;
}

private async Task<Machine> FindMachine()
{
var m = GetMachine();

if (m.Id == Guid.Empty)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Ghosts.Api/ghosts.api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<AssemblyName>ghosts.api</AssemblyName>

<AssemblyVersion>8.0.0.0</AssemblyVersion>
<FileVersion>8.0.6.68</FileVersion>
<FileVersion>8.0.7.0</FileVersion>

<Authors>Dustin Updyke for Carnegie Mellon University</Authors>
<Authors>Dustin Updyke for CERT > Software Engineering Institute > Carnegie Mellon University</Authors>
<Company>Carnegie Mellon University</Company>
<Product>GHOSTS</Product>
<Description>GHOSTS NPC Platform - please email ddupdyke[-at-]sei.cmu.edu with bugs/requests/other</Description>
Expand Down

0 comments on commit 750f4aa

Please sign in to comment.