-
Notifications
You must be signed in to change notification settings - Fork 5
Allow blacklisting CIDR ranges #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
On Sat, Jan 04, 2025 at 05:41:54PM GMT, Daniel Saxton wrote:
Enables CIDR blocking in case a spammer is using multiple IP addresses in a specific range.
awesome. had the same thought!
|
Nice! Let me know if you think there's a better dependency than |
ideally we would parse the CIDR thing before so we don't have to do it for each incoming message. the best way to do this would probably be some kind of trait with an associative type so that we convert it to the parsed version of the struct after deserializing. the associative type could just be itself if there is no difference in the parsed structure. example: trait NoteguardConfig {
type Parsed
fn to_parsed(&self) -> Self::Parsed {
}
}
impl NoteguardConfig for Blacklist {
type Parsed = ParsedBlacklist;
fn to_parsed(&self) -> Self::Parsed {
// note: I haven't tested this it's off the top of my head
let ips = self.ips.iter().filter_map(IpNetwork::from_str);
ParsedBlacklist {
ips
}
}
} Then we can do this automatically somewhere when we are reading the config. |
Alternatively we can do custom deserialization directly on the type somehow, I haven't touched this code in awhile so the proper way to do it isn't floating in my head anywhere at the moment |
Sorry for the delay here. I applied this suggestion and tests still seem to be passing. Was this roughly what you had in mind? |
yeah that's great. thanks! |
just need docs and then we'll be good to merge! |
Docs updated 👍 |
holy crap sorry for the delay, found this at the bottom of my dev inbox |
Enables CIDR blocking in case a spammer is using multiple IP addresses in a specific range.