Comments (1)
Good question!
Here's the best approach that comes to mind. It's a little manual...but not too bad.
# Set up a typical blacklist with Allow2Ban filter:
Rack::Attack.blacklist('allow2ban scraper') do |req|
result = Rack::Attack::Allow2Ban.filter(req.ip, maxretry: 20, findtime: 5.seconds, bantime: 1.hour) do
true
end
# But instead of returning the result of Allow2Ban.filter, we track it
if result
# Log it or whatever
puts "This request would have been blocked"
end
# Return false so the request is not blocked.
false
end
Then when you're ready to enable it in production, you just delete the extra bit after the Allow2Ban.filter
block.
from rack-attack.
Related Issues (20)
- Way to decrement from throttle after processing a request HOT 1
- Is Rack::Attack.reset! supposed to clear .blocklist and .safelist? HOT 2
- Wondering if is any plan to release some of the features that are on the main branch HOT 1
- Redis pipelining deprecation errors HOT 2
- Why Fail2Ban#fail! always return true? HOT 1
- How to get blocked ips?
- Ex is stopping me from getting direct messages and is intercepting my iPhone activity how to fix
- Use of safelist_ip causes error when IP address is not set
- Rack Attack with black-listed IP's still letting those IPs in on Heroku HOT 3
- Rails request throttling just half the given limit
- Rack 3 Support HOT 4
- Using `matched_by?` without rack-attack hijacking HTTP response? HOT 1
- Checking Limits Without Incrementing? HOT 1
- Metadata retention mechanism when limit/period procs are used on throttles
- Throttling period is not "rolling" HOT 1
- Feature Request: Block everything your routes.rb doesn't specify!
- Wrong Number of arguments (given 3, expected 2) HOT 1
- The CHANGELOG seems to be missing info about v6.7.0 HOT 4
- security policy HOT 1
- Feature request: testing helpers HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rack-attack.