I am using a rate limiter and want to restrict/ban/block a client IP address from contacting my server.
I want this to protect my server from going down during a brute force attack of millions of requests per minute.
How do I programatically block and unblock a client IP so that my server resources are not wasted?
install(RateLimit) {
global {
rateLimiter(limit = 10, refillPeriod = 10.seconds)
requestKey { call -> call.request.origin.remoteAddress }
}
}
install(StatusPages) {
status(HttpStatusCode.TooManyRequests) { call, status ->
call.respondText(text = "429: Too many requests. You are now blocked.", status = status)
call.remoteAddress //how to block this address now?
}
}