mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 02:08:04 +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
@@ -33,6 +33,10 @@ public interface RateLimiter {
|
||||
validate(accountUuid.toString());
|
||||
}
|
||||
|
||||
default void validate(final UUID accountUuid, final int permits) throws RateLimitExceededException {
|
||||
validate(accountUuid.toString(), permits);
|
||||
}
|
||||
|
||||
default void validate(final UUID srcAccountUuid, final UUID dstAccountUuid) throws RateLimitExceededException {
|
||||
validate(srcAccountUuid.toString() + "__" + dstAccountUuid.toString());
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ public class RateLimiters extends BaseRateLimiters<RateLimiters.For> {
|
||||
RECAPTCHA_CHALLENGE_SUCCESS("recaptchaChallengeSuccess", true, new RateLimiterConfig(2, Duration.ofMinutes(12))),
|
||||
PUSH_CHALLENGE_ATTEMPT("pushChallengeAttempt", true, new RateLimiterConfig(10, Duration.ofSeconds(144))),
|
||||
PUSH_CHALLENGE_SUCCESS("pushChallengeSuccess", true, new RateLimiterConfig(2, Duration.ofMinutes(12))),
|
||||
CREATE_CALL_LINK("createCallLink", false, new RateLimiterConfig(100, Duration.ofSeconds(15)));
|
||||
CREATE_CALL_LINK("createCallLink", false, new RateLimiterConfig(100, Duration.ofSeconds(15))),
|
||||
INBOUND_MESSAGE_BYTES("inboundMessageBytes", true, new RateLimiterConfig(128 * 1024 * 1024, Duration.ofNanos(500_000)));
|
||||
|
||||
private final String id;
|
||||
|
||||
@@ -211,4 +212,8 @@ public class RateLimiters extends BaseRateLimiters<RateLimiters.For> {
|
||||
public RateLimiter getCreateCallLinkLimiter() {
|
||||
return forDescriptor(For.CREATE_CALL_LINK);
|
||||
}
|
||||
|
||||
public RateLimiter getInboundMessageBytes() {
|
||||
return forDescriptor(For.INBOUND_MESSAGE_BYTES);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user