parent
917eaa50fb
commit
e07c521288
|
@ -26,6 +26,9 @@ public class RateLimitsConfiguration {
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private RateLimitConfiguration voiceDestination = new RateLimitConfiguration(2, 1.0 / 2.0);
|
private RateLimitConfiguration voiceDestination = new RateLimitConfiguration(2, 1.0 / 2.0);
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
private RateLimitConfiguration voiceDestinationDaily = new RateLimitConfiguration(10, 10.0 / (24.0 * 60.0));
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private RateLimitConfiguration verifyNumber = new RateLimitConfiguration(2, 2);
|
private RateLimitConfiguration verifyNumber = new RateLimitConfiguration(2, 2);
|
||||||
|
|
||||||
|
@ -79,6 +82,10 @@ public class RateLimitsConfiguration {
|
||||||
return voiceDestination;
|
return voiceDestination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RateLimitConfiguration getVoiceDestinationDaily() {
|
||||||
|
return voiceDestinationDaily;
|
||||||
|
}
|
||||||
|
|
||||||
public RateLimitConfiguration getVerifyNumber() {
|
public RateLimitConfiguration getVerifyNumber() {
|
||||||
return verifyNumber;
|
return verifyNumber;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,7 @@ public class AccountController {
|
||||||
break;
|
break;
|
||||||
case "voice":
|
case "voice":
|
||||||
rateLimiters.getVoiceDestinationLimiter().validate(number);
|
rateLimiters.getVoiceDestinationLimiter().validate(number);
|
||||||
|
rateLimiters.getVoiceDestinationDailyLimiter().validate(number);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new WebApplicationException(Response.status(422).build());
|
throw new WebApplicationException(Response.status(422).build());
|
||||||
|
|
|
@ -25,6 +25,7 @@ public class RateLimiters {
|
||||||
|
|
||||||
private final RateLimiter smsDestinationLimiter;
|
private final RateLimiter smsDestinationLimiter;
|
||||||
private final RateLimiter voiceDestinationLimiter;
|
private final RateLimiter voiceDestinationLimiter;
|
||||||
|
private final RateLimiter voiceDestinationDailyLimiter;
|
||||||
private final RateLimiter verifyLimiter;
|
private final RateLimiter verifyLimiter;
|
||||||
|
|
||||||
private final RateLimiter attachmentLimiter;
|
private final RateLimiter attachmentLimiter;
|
||||||
|
@ -44,6 +45,10 @@ public class RateLimiters {
|
||||||
config.getVoiceDestination().getBucketSize(),
|
config.getVoiceDestination().getBucketSize(),
|
||||||
config.getVoiceDestination().getLeakRatePerMinute());
|
config.getVoiceDestination().getLeakRatePerMinute());
|
||||||
|
|
||||||
|
this.voiceDestinationDailyLimiter = new RateLimiter(cacheClient, "voxDestinationDaily",
|
||||||
|
config.getVoiceDestinationDaily().getBucketSize(),
|
||||||
|
config.getVoiceDestinationDaily().getLeakRatePerMinute());
|
||||||
|
|
||||||
this.verifyLimiter = new RateLimiter(cacheClient, "verify",
|
this.verifyLimiter = new RateLimiter(cacheClient, "verify",
|
||||||
config.getVerifyNumber().getBucketSize(),
|
config.getVerifyNumber().getBucketSize(),
|
||||||
config.getVerifyNumber().getLeakRatePerMinute());
|
config.getVerifyNumber().getLeakRatePerMinute());
|
||||||
|
@ -106,6 +111,10 @@ public class RateLimiters {
|
||||||
return voiceDestinationLimiter;
|
return voiceDestinationLimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RateLimiter getVoiceDestinationDailyLimiter() {
|
||||||
|
return voiceDestinationDailyLimiter;
|
||||||
|
}
|
||||||
|
|
||||||
public RateLimiter getVerifyLimiter() {
|
public RateLimiter getVerifyLimiter() {
|
||||||
return verifyLimiter;
|
return verifyLimiter;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue