Skip to content

Commit

Permalink
deny arenaInformation query
Browse files Browse the repository at this point in the history
  • Loading branch information
area363 committed Sep 13, 2023
1 parent 9be6f9b commit 344f09c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions NineChronicles.Headless/Middleware/HttpCaptureMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ public async Task InvokeAsync(HttpContext context)
}
}

if (body.Contains("arenaInformation"))
{
try
{
_logger.Information("[GRAPHQL-REQUEST-CAPTURE] Cancelling ArenaInformation Query from IP: {IP}",
remoteIp);
await CancelRequestAsync(context);
return;
}
catch (Exception ex)
{
_logger.Error(
"[GRAPHQL-REQUEST-CAPTURE-SIGNER] Error message: {message} Stacktrace: {stackTrace}",
ex.Message,
ex.StackTrace);
}
}

if (body.Contains("stageTransaction"))
{
try
Expand Down Expand Up @@ -172,5 +190,13 @@ private void AddClientIpInfo(Address agentAddress, string ipAddress)
{
_publisher.AddClientAndIp(ipAddress, agentAddress.ToString());
}

private async Task CancelRequestAsync(HttpContext context)
{
var message = "{ \"message\": \"Request cancelled.\" }";
context.Response.StatusCode = 403;
context.Response.ContentType = "application/json";
await context.Response.WriteAsync(message);
}
}
}

0 comments on commit 344f09c

Please sign in to comment.