mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 02:28:05 +01:00
Add a rate limit for inbound message bytes for a given account
This commit is contained in:
committed by
Jon Chambers
parent
e38a713ccc
commit
e87468fbe0
@@ -186,9 +186,7 @@ public class MessageController {
|
||||
@PathParam("destination") UUID destinationUuid,
|
||||
@QueryParam("story") boolean isStory,
|
||||
@NotNull @Valid IncomingMessageList messages,
|
||||
@Context ContainerRequestContext context
|
||||
)
|
||||
throws RateLimitExceededException {
|
||||
@Context ContainerRequestContext context) throws RateLimitExceededException {
|
||||
|
||||
if (source.isEmpty() && accessKey.isEmpty() && !isStory) {
|
||||
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
|
||||
@@ -213,8 +211,9 @@ public class MessageController {
|
||||
spamReportToken = Optional.empty();
|
||||
}
|
||||
|
||||
for (final IncomingMessage message : messages.messages()) {
|
||||
int totalContentLength = 0;
|
||||
|
||||
for (final IncomingMessage message : messages.messages()) {
|
||||
int contentLength = 0;
|
||||
|
||||
if (!Util.isEmpty(message.content())) {
|
||||
@@ -223,8 +222,12 @@ public class MessageController {
|
||||
|
||||
validateContentLength(contentLength, userAgent);
|
||||
validateEnvelopeType(message.type(), userAgent);
|
||||
|
||||
totalContentLength += contentLength;
|
||||
}
|
||||
|
||||
rateLimiters.getInboundMessageBytes().validate(destinationUuid, totalContentLength);
|
||||
|
||||
try {
|
||||
boolean isSyncMessage = source.isPresent() && source.get().getAccount().isIdentifiedBy(destinationUuid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user