Added comment.
This commit is contained in:
parent
7af0708c40
commit
0e3881dcac
|
@ -60,12 +60,15 @@ void handleVisitorLog(ref HttpRequestContext ctx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string remoteAddress = ctx.request.getHeader("X-Forwarded-For");
|
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);
|
LogEntry[] recentLogsByThisAddress = getRecentLogEntriesByRemoteAddress(remoteAddress);
|
||||||
SysTime now = Clock.currTime();
|
SysTime now = Clock.currTime();
|
||||||
if (recentLogsByThisAddress.length > 0 && now - recentLogsByThisAddress[0].createdAt < minutes(1)) {
|
if (recentLogsByThisAddress.length > 0 && now - recentLogsByThisAddress[0].createdAt < minutes(1)) {
|
||||||
ctx.response.setStatus(HttpStatus.TOO_MANY_REQUESTS);
|
ctx.response.setStatus(HttpStatus.TOO_MANY_REQUESTS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
insertLogEntry(remoteAddress, name, message);
|
insertLogEntry(remoteAddress, name, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue