Back to Demos
Rate Limit Attack Simulator
Based on KoiRateLimiter pattern from paygate
Attack Controls
Rate Limit Stats
Request Log (Real-time)
No requests yet. Click "Single Request" or "Spam Attack!" to start.
Production Code (Java)
// From paygate/AmunPaygate - KoiRateLimiter.java
public class KoiRateLimiter extends BaseLoggable {
public boolean checkUserIsBlocked(String username, String ipAddress, String action) {
boolean enableRateLimiting = getConfig().getBoolean("enableRateLimiting", false);
if (enableRateLimiting) {
String rateLimitingUrl = getConfig().getString("rateLimitingUrl", "");
PuObject body = new PuObject();
body.setString("ipAddress", ipAddress);
body.setString("username", username);
body.setString("action", action);
try {
HttpResponse<String> response = Unirest.post(rateLimitingUrl)
.header("Content-Type", "application/json")
.body(body.toJSON())
.connectTimeout(1000)
.asString();
PuObject result = PuObject.fromJSON(response.getBody());
int code = result.getInteger("code", 0);
return code == 1; // 1 = blocked
} catch (Exception e) {
getLogger().error("error while check rate limit", e);
}
}
return false;
}
}