Introducing Caddy Defender

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.

Github
Reddit Inception

10 Likes

This is an incredible feature. Thank you for sharing your work. :saluting_face:

:open_mouth: tysm! Still has a lot of room for improvement though

Im working on a PR for fetching/parsing Azure Public Cloud right now :wink: done

1 Like

Amazing. I’ll share this too!

3 Likes

Thanks everyone. Any and all shares, stars, contributions, feedback is absolutely welcome. Work is being done and always room for improvement!

Again, all credit due goes to @json

:beers:

2 Likes

I have created two modules that do something similar:

3 Likes

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!

1 Like

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.

1 Like

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.

1 Like

Interesing, but you had a small typo in the link: GitHub - gaissmai/bart: The Balanced Routing Table is an adaptation of D. Knuth's ART algorithm and requires significantly less memory at comparable speed.

Sorry, where’s the typo? I can’t find it lol. Mind submitting a PR to fix it or point it out. Thanks in advance!

@matt can ownership of this thread be given to @json ?

Also: tfw doing caddy research while on vpn:

You are blocked due to abuse. Speak with your ISP.

Love it :heart: :smiley:

Thanks

We had to block a bunch of AS’es due to severe spam…

Hm, I’m not sure how to transfer topic ownership…

but we can link to a new topic started by @json and close this one?

2 Likes

Ah it’s okay! I don’t mind if someone else owns the thread

1 Like

This was shown while on Mullvad network, so not surprising :smiley: