From 6bc9b993237d7e9ca42dcc8e348ef9cb8bc67d8b Mon Sep 17 00:00:00 2001 From: MCLV <107920484+MCLV-pandorabox@users.noreply.github.com> Date: Tue, 28 Oct 2025 20:53:29 +0100 Subject: [PATCH] Wildcard (subnet) ban support for IPv4 & IPv6 with trailing * notation (#28) This enables banning entire subnets or address groups, with documentation and usage examples updated in the README. No changes to command structure or database, all bans work with standard xban commands. --- README.md | 72 +++++++++++++++++++++++++++++++++++++++---------------- init.lua | 42 +++++++++++++++++--------------- 2 files changed, 75 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 75f8e88..14c74c8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ - # Extended Ban Mod for Minetest - This mod attempts to be an improvement to Minetest's ban system. - * It supports normal bans and temporary bans (from 60 seconds up to the end of time, with 1 second granularity). * Records and joins all accounts using the same IP address and several IP @@ -15,26 +12,70 @@ This mod attempts to be an improvement to Minetest's ban system. * Has an API to ban and check the ban database to allows other mods to manage users (for example, anticheat mods). -## Chat commands +## Wildcard/Subnet Ban Feature +The mod now supports wildcard (subnet) bans for IP addresses using trailing `*` notation. This allows you to ban entire IP ranges or subnets with a single command. + +### How It Works + +* **IPv4 Wildcard Bans**: Use a trailing `*` to match any IP address that starts with the specified prefix. + * Example: `192.168.1.*` will match all IPs from `192.168.1.0` to `192.168.1.255` + * Example: `10.0.*` will match all IPs from `10.0.0.0` to `10.0.255.255` + * Example: `172.*` will match all IPs from `172.0.0.0` to `172.255.255.255` + +* **IPv6 Wildcard Bans**: Use a trailing `*` to match any IPv6 address that starts with the specified prefix. + * Example: `2001:db8:*` will match all IPv6 addresses starting with `2001:db8:` + * Example: `fe80:*` will match all link-local IPv6 addresses + +### Usage Examples + +**Ban an entire IPv4 subnet:** +``` +/xban 192.168.1.* Banning entire subnet due to spam +``` + +**Temporarily ban an IPv4 range:** +``` +/xtempban 10.0.* 24h Temporary subnet ban for suspected bot activity +``` + +**Ban an IPv6 prefix:** +``` +/xban 2001:db8:* Banning IPv6 prefix +``` + +**Unban a wildcard entry:** +``` +/xunban 192.168.1.* +``` + +### Notes + +* Wildcard bans are checked when a player attempts to connect. +* Individual IP addresses can still be whitelisted even if they match a wildcard ban. +* The wildcard character `*` must be at the end of the IP address. +* For IPv4, you can use wildcards at any octet boundary (e.g., `192.*`, `192.168.*`, `192.168.1.*`). +* For IPv6, the wildcard matches the remaining part of the address after the specified prefix. + +## Chat commands The mod provides the following chat commands. All commands require the `ban` privilege. ### `xban` - Bans a player permanently. **Usage:** `/xban ` **Example:** `/xban 127.0.0.1 Some reason.` -### `xtempban` +**Wildcard Example:** `/xban 192.168.1.* Subnet ban` +### `xtempban` Bans a player temporarily. **Usage:** `/xtempban