Compare commits

...
7 Commits
Author SHA1 Message Date
marc d7713db58b Dockerfile
Service CI / build (push) Canceled after 0s
2021-12-23 14:03:11 +01:00
Jon Chambers c21eb6aa50 Update to the latest abusive message filter
Service CI / build (push) Canceled after 0s
2021-11-01 15:27:14 -04:00
Jon Chambers 6dddf54222 Consolidate rate-limit counters
Service CI / build (push) Canceled after 0s
2021-11-01 14:33:05 -04:00
Jon Chambers 9e3eb2319e Update to the latest abusive message filter
Service CI / build (push) Canceled after 0s
2021-11-01 13:12:23 -04:00
Jon Chambers 1d8dcda815 Update to the latest abusive message filter
Service CI / build (push) Canceled after 0s
2021-11-01 12:45:50 -04:00
Jon Chambers ee52a84262 Update to the latest abusive message filter
Service CI / build (push) Canceled after 0s
2021-11-01 12:19:21 -04:00
Jon Chambers eb51e81faa Configuration-only change
Service CI / build (push) Canceled after 0s
2021-11-01 11:41:26 -04:00
3 changed files with 27 additions and 12 deletions
+6
View File
@@ -0,0 +1,6 @@
FROM maven
COPY . /app
WORKDIR /app
RUN mvn install
@@ -125,14 +125,15 @@ public class MessageController {
private final ExecutorService multiRecipientMessageExecutor;
private static final String LEGACY_MESSAGE_SENT_COUNTER = name(MessageController.class, "legacyMessageSent");
private static final String SENT_MESSAGE_COUNTER_NAME = name(MessageController.class, "sentMessages");
private static final String REJECT_UNSEALED_SENDER_COUNTER_NAME = name(MessageController.class, "rejectUnsealedSenderLimit");
private static final String CONTENT_SIZE_DISTRIBUTION_NAME = name(MessageController.class, "messageContentSize");
private static final String SENT_MESSAGE_COUNTER_NAME = name(MessageController.class, "sentMessages");
private static final String CONTENT_SIZE_DISTRIBUTION_NAME = name(MessageController.class, "messageContentSize");
private static final String OUTGOING_MESSAGE_LIST_SIZE_BYTES_DISTRIBUTION_NAME = name(MessageController.class, "outgoingMessageListSizeBytes");
private static final String RATE_LIMITED_MESSAGE_COUNTER_NAME = name(MessageController.class, "rateLimitedMessage");
private static final String EPHEMERAL_TAG_NAME = "ephemeral";
private static final String SENDER_TYPE_TAG_NAME = "senderType";
private static final String EPHEMERAL_TAG_NAME = "ephemeral";
private static final String SENDER_TYPE_TAG_NAME = "senderType";
private static final String SENDER_COUNTRY_TAG_NAME = "senderCountry";
private static final String RATE_LIMIT_REASON_TAG_NAME = "rateLimitReason";
private static final long MAX_MESSAGE_SIZE = DataSize.kibibytes(256).toBytes();
@@ -223,20 +224,28 @@ public class MessageController {
assert (destination.isPresent());
if (source.isPresent() && !source.get().getAccount().getUuid().equals(destinationUuid)) {
rateLimiters.getMessagesLimiter().validate(source.get().getAccount().getUuid(), destination.get().getUuid());
final String senderCountryCode = Util.getCountryCode(source.get().getAccount().getNumber());
try {
rateLimiters.getMessagesLimiter().validate(source.get().getAccount().getUuid(), destination.get().getUuid());
} catch (final RateLimitExceededException e) {
Metrics.counter(RATE_LIMITED_MESSAGE_COUNTER_NAME,
SENDER_COUNTRY_TAG_NAME, senderCountryCode,
RATE_LIMIT_REASON_TAG_NAME, "singleDestinationRate").increment();
throw e;
}
try {
unsealedSenderRateLimiter.validate(source.get().getAccount(), destination.get());
} catch (final RateLimitExceededException e) {
final boolean legacyClient = rateLimitChallengeManager.isClientBelowMinimumVersion(userAgent);
final String rateLimitReason = legacyClient ? "unsealedSenderCardinality" : "challengeIssued";
Metrics.counter(REJECT_UNSEALED_SENDER_COUNTER_NAME,
SENDER_COUNTRY_TAG_NAME, senderCountryCode,
"legacyClient", String.valueOf(legacyClient))
.increment();
Metrics.counter(RATE_LIMITED_MESSAGE_COUNTER_NAME,
SENDER_COUNTRY_TAG_NAME, senderCountryCode,
RATE_LIMIT_REASON_TAG_NAME, rateLimitReason).increment();
if (legacyClient) {
throw e;