A high-performance, thread-safe plugin for Mindustry servers that provides advanced access control through GeoIP blocking and whitelisting.
This plugin is designed to handle high-traffic servers with zero lag on the main thread, using intelligent caching and asynchronous-friendly locking mechanisms.
- GeoIP Blocking: Automatically kick players connecting from specific countries using the MaxMind GeoLite2 database.
- Dual Whitelisting:
- IP Whitelist: Allow specific IP addresses to bypass country checks.
- UUID Whitelist: Allow specific player UUIDs to bypass all checks (ideal for players with dynamic IPs).
- Zero-Latency Checks:
- Smart Caching: Uses
ConcurrentHashMapto cache results for 1 hour. Repeated connections do not touch the disk or database. - Memory-Mapped IO: fast database reading directly from RAM.
- No DNS Lookups: Validates IP patterns via Regex/Parsing to avoid thread-blocking DNS queries.
- Smart Caching: Uses
- Thread Safe: Built with
ReadWriteLockarchitecture, allowing safe hot-reloading of the configuration while players are connecting.
To compile the plugin yourself, you need a Java Development Kit (JDK) installed (JDK 17 is recommended).
- Open a terminal in the project directory.
- Run the build command:
- Windows:
gradlew jar
- Linux / macOS:
./gradlew jar
- Windows:
- The compiled plugin will be located in:
build/libs/
⚠️ Important for Developers: This plugin relies on Jackson (jackson-databind) and MaxMind (maxmind-db) libraries. Yourbuild.gradlemust be configured to shadow (shade) these dependencies into the final JAR file, otherwise the plugin will crash withNoClassDefFoundErrorat runtime.
-
Download/Build the Plugin: Place the
BlockIp.jarinto your server'sconfig/modsfolder. -
Download the GeoIP Database:
- This plugin requires a MaxMind
.mmdbdatabase. - Sign up for free at MaxMind and download the GeoLite2-Country database.
- This plugin requires a MaxMind
-
Initial Run: Start the server once. The plugin will generate the necessary folders but will log a warning that the database is missing.
-
Setup Database:
- Navigate to:
config/mods/blockip/ - Rename your downloaded database file to
ip.mmdb. - Place it inside the folder so the path is:
config/mods/blockip/ip.mmdb.
- Navigate to:
-
Reload: Type
blockipreloadin the server console to load the database without restarting.
The configuration file is located at config/mods/blockip/config.json.
When generated, the file looks like this:
{
"blockedCountries" : [ ],
"ipWhiteList" : [ ],
"uuidWhiteList" : [ ],
"kickText" : "Your country is blocked on this server."
}| Field | Type | Description |
|---|---|---|
blockedCountries |
Array | A list of 2-letter ISO-3166 country codes to block (e.g., ["CN", "RU"]). |
ipWhiteList |
Array | Specific IPs that can join even if their country is blocked (e.g., ["127.0.0.1"]). |
uuidWhiteList |
Array | Mindustry Client UUIDs that can join from any IP/Country. |
kickText |
String | The message displayed to the player when they are disconnected. |
All commands are intended for the Server Console.
| Command | Arguments | Description |
|---|---|---|
blockipreload |
(none) | Reloads config.json and ip.mmdb. Clears the internal cache. |
addcountry |
<country_code> |
Adds a 2-letter code to the blocklist (e.g., addcountry US). |
removecountry |
<country_code> |
Removes a country code from the blocklist. |
addwhitelist |
<ip> |
Adds an IP address to the whitelist. |
removewhitelist |
<ip> |
Removes an IP address from the whitelist. |
adduuid |
<uuid> |
Adds a player UUID to the whitelist. |
removeuuid |
<uuid> |
Removes a player UUID from the whitelist. |
- "MaxMind DB reader is not initialized" Error:
- Ensure the file is named exactly
ip.mmdb. - Ensure it is located in
config/mods/blockip/. - Run
blockipreloadafter placing the file.
- Ensure the file is named exactly
- Changes to config.json are not working:
- You must run
blockipreloador restart the server for manual file edits to take effect.
- You must run
- IPv6 Support:
- The plugin supports GeoIP blocking for IPv6.
- Note: The
addwhitelistcommand currently validates for IPv4 patterns. To whitelist an IPv6 address, add it manually toconfig.jsonand reload.
This product uses GeoLite2 data created by MaxMind, available from https://www.maxmind.com.