From 0e3881dcacfd4d2538dddae9db909e5ad77337e3 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Sun, 23 Jul 2023 20:01:02 -0400 Subject: [PATCH] Added comment. --- source/app.d | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/app.d b/source/app.d index a2e56bf..7e82536 100644 --- a/source/app.d +++ b/source/app.d @@ -60,12 +60,15 @@ void handleVisitorLog(ref HttpRequestContext ctx) { return; } string remoteAddress = ctx.request.getHeader("X-Forwarded-For"); + + // If the user has sent another log within the last minute, block this one. LogEntry[] recentLogsByThisAddress = getRecentLogEntriesByRemoteAddress(remoteAddress); SysTime now = Clock.currTime(); if (recentLogsByThisAddress.length > 0 && now - recentLogsByThisAddress[0].createdAt < minutes(1)) { ctx.response.setStatus(HttpStatus.TOO_MANY_REQUESTS); return; } + insertLogEntry(remoteAddress, name, message); }