mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-23 21:51:29 +00:00
Implement POST request rate limiting (#490)
* Initial work for rate limiting * Refactor GameServerStartup and change default rate limit config * Adjust config naming and add Enabled option to global and override rate limits * Fix LBP3 republish bug * Fix bugs in rate limiting and allow for multiple matched overrides * Add this qualifier for private variable * Changes from self review
This commit is contained in:
parent
110d81f117
commit
3ad211e5c8
16 changed files with 451 additions and 206 deletions
|
@ -0,0 +1,29 @@
|
|||
using LBPUnion.ProjectLighthouse.Middlewares;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
|
||||
|
||||
public class SetLastContactMiddleware : MiddlewareDBContext
|
||||
{
|
||||
public SetLastContactMiddleware(RequestDelegate next) : base(next)
|
||||
{ }
|
||||
|
||||
public override async Task InvokeAsync(HttpContext context, Database database)
|
||||
{
|
||||
#nullable enable
|
||||
// Log LastContact for LBP1. This is done on LBP2/3/V on a Match request.
|
||||
if (context.Request.Path.ToString().StartsWith("/LITTLEBIGPLANETPS3_XML"))
|
||||
{
|
||||
// We begin by grabbing a token from the request, if this is a LBPPS3_XML request of course.
|
||||
GameToken? gameToken = await database.GameTokenFromRequest(context.Request);
|
||||
|
||||
if (gameToken?.GameVersion == GameVersion.LittleBigPlanet1)
|
||||
// Ignore UserFromGameToken null because user must exist for a token to exist
|
||||
await LastContactHelper.SetLastContact
|
||||
(database, (await database.UserFromGameToken(gameToken))!, GameVersion.LittleBigPlanet1, gameToken.Platform);
|
||||
}
|
||||
#nullable disable
|
||||
|
||||
await this.next(context);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue