Not my work. Is the result of a Reddit discussion earlier today. Call it self care
Caddy Defender Plugin
The Caddy Defender plugin is a middleware for Caddy that allows you to block or manipulate requests based on the client’s IP address. It is particularly useful for preventing unwanted traffic or polluting AI training data by returning garbage responses.
Features
IP Range Filtering: Block or manipulate requests from specific IP ranges.
Embedded IP Ranges: Predefined IP ranges for popular AI services (e.g., OpenAI, DeepSeek, GitHub Copilot).
Custom IP Ranges: Add your own IP ranges via Caddyfile configuration.
Multiple Responder Backends:
Block: Return a 403 Forbidden response.
Garbage: Return garbage data to pollute AI training.
Custom: Return a custom message.
Oo your block AWS plugin is super interesting.
I do have an AWS matching as well as specific region matching. But it looks like you’re IP matching library is a lot more efficient than mine, so I’m going to have to look into that library. Thank you!
I used a tree structure for IPs for efficient range lookups. Have not really benchmarked it, but I looked at the code and it made sense to use byte range queries for IPs.
I’ve since updated my plugin to use an ART-based structure. specifically https://github.com/gaissmai/barts, some quick testing showed it to be a whole lot faster + the cache has been switched over to sturdyc.