Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ade6115
chore(release): start 1.2.0
rayhandestian Nov 7, 2026
8e60264
feat(rules): add the allow-networks rule
rayhandestian Nov 7, 2026
ec0eaf4
fix(rules): match allow-networks by AS number only
rayhandestian Nov 7, 2026
a1fd412
feat(lists): store allow and deny entries with expiry
rayhandestian Nov 7, 2026
8c51fec
fix(lists): handle every storage failure when reading or writing lists
rayhandestian Nov 7, 2026
6c9c7ab
feat(rules): check the allow and deny lists before any lookup
rayhandestian Nov 7, 2026
fea84c4
feat(commands): add allow and deny list commands
rayhandestian Nov 7, 2026
bdcfd65
fix(commands): disconnect only players the deny list now turns away
rayhandestian Nov 7, 2026
db649ec
feat(rules): add the accounts-per-ip rule
rayhandestian Nov 7, 2026
5944c9b
feat(alerts): post kicks, bypasses, and lookup alerts to a Discord we…
rayhandestian Nov 7, 2026
490192c
test(probes): check the 1.2.0 changes on real Velocity
rayhandestian Nov 7, 2026
77eb526
docs: describe 1.2.0
rayhandestian Nov 7, 2026
56669ba
test(probes): fail check 25 when the player stays connected
rayhandestian Nov 7, 2026
0b742ed
fix(alerts): keep IP addresses out of Discord posts unless show-ip is on
rayhandestian Nov 7, 2026
399c4fc
fix(lists): refresh shared lists every 30 seconds and keep them acros…
rayhandestian Nov 7, 2026
a9a3b3f
fix(alerts): hide addresses that carry a port or a trailing colon in …
rayhandestian Nov 7, 2026
35b2be4
fix(commands): a failing kick check never blocks the deny add reply
rayhandestian Nov 7, 2026
4aad5d7
test(config): check the 1.1.1 default config and messages still load
rayhandestian Nov 7, 2026
657818b
docs: list new 1.2.0 settings, two tables, and same-moment logins
rayhandestian Nov 7, 2026
fa53529
fix(net): never hand text that cannot be an IP literal to the resolver
rayhandestian Nov 7, 2026
0f89a31
fix(alerts): end the note with a full stop before the caution in Disc…
rayhandestian Nov 7, 2026
323b787
test(net): count resolver lookups to prove address parsing never asks…
rayhandestian Nov 7, 2026
6da5744
docs: note the platforms' own limits on repeat logins from one address
rayhandestian Nov 7, 2026
9d317b4
fix(commands): need the other list's permission to replace its entry
rayhandestian Nov 12, 2026
4675cc5
fix(velocity): skip players without an address when counting accounts…
rayhandestian Nov 12, 2026
fb158ba
fix(lists): refuse mistyped addresses and store a range by its networ…
rayhandestian Nov 12, 2026
936a8be
fix(commands): refuse a mistyped duration instead of saving it as the…
rayhandestian Nov 12, 2026
bb66b22
fix(lists): keep the entries when a reload falls back to memory-only …
rayhandestian Nov 12, 2026
b26975a
fix(alerts): hide addresses in lookup answers and keep the IP and cau…
rayhandestian Nov 12, 2026
26035be
docs: say dry-run bypasses are not posted to Discord either
rayhandestian Nov 12, 2026
6715f4a
docs: say dry-run bypasses are not posted in the privacy page too
rayhandestian Nov 12, 2026
97919c6
chore(release): 1.2.0
rayhandestian Nov 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 1.2.0 (2026-11-16)

### Upgrading from 1.1.x

Replace the JAR and restart. Your `config.yml` and `messages.yml` keep working unchanged and behave as before: every new setting is optional and off when missing, and missing new messages use the bundled text. The new `origingate_list` table is created automatically. To use the new features, copy the whole new section from the [default config](https://github.com/kaizen-network/OriginGate/blob/main/core/src/main/resources/config.yml): a `discord` or `accounts-per-ip` section with a missing inner key is refused.

### Added

- `allow-networks` rule: lets in networks you list by AS number when the `vpn`, `proxy`, or `hosting` rule would kick them, for example a school or mobile carrier that a provider wrongly flags. `deny-networks` and `country` still apply. Off by default.
- Storage for allow and deny list entries (table `origingate_list`, created automatically). Entries can expire, carry a note, and are kept in memory, so logins never wait on the database.
- The allow and deny lists are checked on every login before any lookup. A deny list entry kicks with the new `deny-list` rule and message (`kick.deny-list`, bundled text is used when missing). An allow list entry lets the player in with no lookup. `origingate status` shows the entry counts. The hourly cleanup deletes expired entries.
- Commands `origingate allow` and `origingate deny` with `add <player|ip|cidr> [duration] [note]`, `remove`, and `list [page]`, with separate permissions `origingate.command.allow` and `origingate.command.deny`. `deny add` disconnects matching players who are online on that server.
- `accounts-per-ip` rule: kicks a player when `max` players (1 to 100, default 3) are already online from exactly the same address, with the new `accounts-per-ip` message (`kick.accounts-per-ip`, bundled text is used when missing). It counts players on this server or proxy only, has no bypass permissions (use the allow list), and is off by default.
- Discord webhook: set `discord.webhook-url` to post kicks, bypasses, and lookup problems and recoveries to a Discord channel. Posts within 5 seconds are combined, up to 10 lines each, then `And <n> more.`. Player and network text is escaped and posts never ping anyone. IP addresses are left out unless `discord.show-ip` is `true`. The URL must be https, is never logged, and the webhook is off while it is empty. `origingate status` shows `Discord webhook: on` or `off`.

## 1.1.1 (2026-11-07)

### Fixed
Expand Down
4 changes: 3 additions & 1 deletion MODRINTH.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ Kick players who connect through a VPN or proxy, or from a country you do not al
## Features

- Rules for VPNs, proxies (with allowed countries), hosting and datacenter networks, country allowlists or denylists, networks by AS number or name, and IP addresses or ranges you list.
- Every rule has its own bypass permissions, plus a global bypass by player, IP, or permission.
- Most rules have their own bypass permissions (the deny-list and accounts-per-ip rules have none, and allow-networks is an allow rule), plus a global bypass by player, IP, or permission.
- IP data from proxycheck.io, IPHub, ip-api.com, IPinfo, or a local MaxMind GeoLite2 file. Combine them, with fallback to the next one.
- Each IP is looked up at most once every 30 days by default, saved in SQLite or MySQL/MariaDB.
- Allow and deny lists you manage with `origingate allow` and `origingate deny`, with optional expiry, and a rule that lets in networks you list by AS number.
- A limit on players online from one address (`accounts-per-ip`), and an optional Discord webhook for kicks and bypasses.
- Dry-run mode shows who would be kicked, without kicking anyone.
- One console line per check, daily log files, and staff alerts in chat, including when a lookup provider stops answering. `origingate status` shows how lookups are doing.
- A lookups-per-minute limit keeps bot floods from using up your provider's daily quota.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ OriginGate checks where each player connects from on Bukkit/Spigot/Paper, Bungee

- IP data from proxycheck.io, IPHub, ip-api.com, IPinfo, or a local MaxMind GeoLite2 file. You choose which, and can combine them.
- Lookups are saved (SQLite, or MySQL/MariaDB), so each IP is looked up at most once every 30 days by default.
- Rules for VPNs, proxies, hosting networks, countries, and networks or addresses you list. Every rule is optional and has its own bypass permissions.
- Rules for VPNs, proxies, hosting networks, countries, and networks or addresses you list. Every rule is optional. Most have their own bypass permissions; the deny-list and accounts-per-ip rules have none (use the allow list), and allow-networks is an allow rule.
- Staff alerts when a lookup provider stops answering, `origingate status`, and a lookups-per-minute limit against bot floods.
- Allow and deny lists you manage with commands, entries that can expire, a limit on players per address, and an optional Discord webhook.
- Dry-run mode shows what would happen without kicking anyone.

## Requirements
Expand Down
215 changes: 213 additions & 2 deletions core/src/main/java/io/github/origingate/core/Commands.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,54 @@
package io.github.origingate.core;

import io.github.origingate.core.lists.ListEntry;
import io.github.origingate.core.lookup.IpInfo;
import io.github.origingate.core.lookup.LookupService;
import io.github.origingate.core.net.Addresses;
import io.github.origingate.core.report.DecisionLine;
import io.github.origingate.core.rules.Decision;
import io.github.origingate.core.rules.LoginAttempt;
import io.github.origingate.core.rules.Rule;

import java.net.InetAddress;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Arrays;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/** {@code /origingate check|status|reload|cache clear}, independent of the platform. */
/** {@code /origingate check|status|reload|cache clear|allow|deny}, independent of the platform. */
public final class Commands {
public static final String CHECK = "origingate.command.check";
public static final String RELOAD = "origingate.command.reload";
public static final String CACHE = "origingate.command.cache";
public static final String STATUS = "origingate.command.status";
public static final String ALLOW = "origingate.command.allow";
public static final String DENY = "origingate.command.deny";
/** Every command permission, for platforms that look them up before running a command elsewhere. */
public static final List<String> PERMISSIONS = io.github.origingate.core.util.Compat.list(CHECK, STATUS, RELOAD, CACHE);
public static final List<String> PERMISSIONS = io.github.origingate.core.util.Compat.list(CHECK, STATUS, RELOAD, CACHE, ALLOW, DENY);
private static final DateTimeFormatter LIST_TIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm z");
private static final Pattern DURATION = Pattern.compile("([0-9]+)([smhdw])");
private static final int PAGE_SIZE = 10;
private static final int MAX_NOTE = 255;
private static final long MAX_SECONDS = 3650L * 86400;
private static final DateTimeFormatter TIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");

public interface Sender {
boolean hasPermission(String permission);

/** May be called from any thread. */
void reply(String line);

/** Who ran the command, for the list entries they add. */
default String name() { return "console"; }
}

public interface Platform {
Expand All @@ -45,6 +62,9 @@ public interface Platform {

/** Loads the files again. Returns the message to show. */
String reload();

/** Disconnects every online player the test matches, with the kick message of the decision's rule. Called from a worker thread. */
default void kick(Predicate<LoginAttempt> who, Decision decision) { }
}

private final Platform platform;
Expand Down Expand Up @@ -92,17 +112,194 @@ public void execute(String[] args, Sender sender) {
clear(args[2], sender);
break;
}
case "allow":
case "deny": {
ListEntry.Kind kind = kindOf(sub);
if (!allowed(sender, permission(kind))) return;
list(kind, args, sender);
break;
}
default: usage(sender);
}
}

private static ListEntry.Kind kindOf(String word) {
return word.equalsIgnoreCase("allow") ? ListEntry.Kind.ALLOW : word.equalsIgnoreCase("deny") ? ListEntry.Kind.DENY : null;
}

private static String permission(ListEntry.Kind kind) { return kind == ListEntry.Kind.ALLOW ? ALLOW : DENY; }

private static String listUsage(ListEntry.Kind kind) {
return "Usage: /origingate " + kind.id() + " add <player|ip|cidr> [duration] [note], remove <player|ip|cidr>, list [page]";
}

private void list(ListEntry.Kind kind, String[] args, Sender sender) {
String action = args.length < 2 ? "" : args[1].toLowerCase(Locale.ROOT);
int page = 1;
boolean valid;
switch (action) {
case "add": valid = args.length >= 3; break;
case "remove": valid = args.length == 3; break;
case "list":
valid = args.length <= 3;
if (valid && args.length == 3) {
try {
page = Integer.parseInt(args[2]);
} catch (NumberFormatException ex) {
page = 0;
}
valid = page >= 1;
}
break;
default: valid = false;
}
if (!valid) {
sender.reply(listUsage(kind));
return;
}
OriginGateRuntime runtime = running(sender);
if (runtime == null) return;
if (action.equals("add")) add(runtime, kind, args, sender);
else if (action.equals("remove")) remove(runtime, kind, args[2], sender);
else show(runtime, kind, page, sender);
}

private void add(OriginGateRuntime runtime, ListEntry.Kind kind, String[] args, Sender sender) {
String target;
try {
target = ListEntry.normalize(args[2]);
} catch (IllegalArgumentException ex) {
sender.reply(ex.getMessage());
return;
}
Instant now = Instant.now();
Instant expires = null;
int noteFrom = 3;
if (args.length > 3) {
String word = args[3].toLowerCase(Locale.ROOT);
Matcher duration = DURATION.matcher(word);
if (word.equals("never")) {
noteFrom = 4;
} else if (duration.matches()) {
long seconds = seconds(duration);
if (seconds < 1 || seconds > MAX_SECONDS) {
sender.reply("Durations go from 1s to 3650d, or never.");
return;
}
expires = now.plusSeconds(seconds);
noteFrom = 4;
} else if (!word.isEmpty() && Character.isDigit(word.charAt(0))) {
// A mistyped duration (30min, 1y) would otherwise start the note and the entry would never expire.
sender.reply(args[3] + " is not a duration. Use s, m, h, d, or w, like 30m or 7d. For a note that starts with a number, put never first.");
return;
}
}
String note = String.join(" ", Arrays.copyOfRange(args, noteFrom, args.length));
if (note.length() > MAX_NOTE) {
sender.reply("Notes can be up to " + MAX_NOTE + " characters.");
return;
}
ListEntry entry = new ListEntry(kind, target, expires, note.isEmpty() ? null : note, sender.name(), now);
// Replacing the target's entry on the other list needs that list's permission too.
ListEntry.Kind other = kind == ListEntry.Kind.ALLOW ? ListEntry.Kind.DENY : ListEntry.Kind.ALLOW;
runtime.lists().add(entry, sender.hasPermission(permission(other))).whenComplete((added, error) -> {
if (error != null) {
sender.reply("Could not change the " + kind.id() + " list: " + Text.message(error));
return;
}
if (!added) {
sender.reply(target + " is on the " + other.id() + " list. Changing that list needs " + permission(other) + ".");
return;
}
boolean dryRun = runtime.config().dryRun();
if (kind == ListEntry.Kind.DENY && !dryRun) {
// Exactly the players the login check would now turn away by the deny list (bypasses and allow entries spare the rest).
try {
platform.kick(attempt -> {
try {
Optional<Decision> verdict = runtime.gate().beforeLookup(attempt);
return verdict.isPresent() && verdict.get().outcome() == Decision.Outcome.DENY && verdict.get().rule() == Rule.DENY_LIST;
} catch (RuntimeException ex) {
return false;
}
}, new Decision(Decision.Outcome.DENY, Rule.DENY_LIST, entry.note(), null, false));
} catch (RuntimeException ex) {
// The entry is saved, so the reply below still goes out.
}
}
String text = "Added " + target + " to the " + kind.id() + " list, " + expiry(entry.expiresAt())
+ (entry.note() == null ? "" : ", note: " + entry.note()) + ".";
if (!runtime.lists().persistent()) text += " Kept in memory only until a restart.";
if (kind == ListEntry.Kind.DENY && dryRun) text += " Dry run is on: nobody online is disconnected.";
sender.reply(text);
});
}

/** Seconds in a duration such as 7d, or -1 when the number is too big to be in range. */
private static long seconds(Matcher duration) {
String digits = duration.group(1);
if (digits.length() > 10) return -1;
long unit;
switch (duration.group(2)) {
case "s": unit = 1; break;
case "m": unit = 60; break;
case "h": unit = 3600; break;
case "d": unit = 86400; break;
default: unit = 604800;
}
return Long.parseLong(digits) * unit;
}

private static String expiry(Instant expires) {
return expires == null ? "never expires" : "expires " + LIST_TIME.format(expires.atZone(ZoneId.systemDefault()));
}

private void remove(OriginGateRuntime runtime, ListEntry.Kind kind, String input, Sender sender) {
String target;
try {
target = ListEntry.normalize(input);
} catch (IllegalArgumentException ex) {
sender.reply(ex.getMessage());
return;
}
runtime.lists().remove(kind, target).whenComplete((removed, error) -> {
if (error != null) sender.reply("Could not change the " + kind.id() + " list: " + Text.message(error));
else sender.reply(removed ? "Removed " + target + " from the " + kind.id() + " list." : target + " is not on the " + kind.id() + " list.");
});
}

private void show(OriginGateRuntime runtime, ListEntry.Kind kind, int page, Sender sender) {
runtime.lists().active(kind).whenComplete((entries, error) -> {
if (error != null) {
sender.reply("Could not read the " + kind.id() + " list: " + Text.message(error));
return;
}
if (entries.isEmpty()) {
sender.reply("The " + kind.id() + " list is empty.");
return;
}
int pages = (entries.size() + PAGE_SIZE - 1) / PAGE_SIZE;
if (page > pages) {
sender.reply("There is no page " + page + ". The " + kind.id() + " list has " + pages + (pages == 1 ? " page." : " pages."));
return;
}
sender.reply((kind == ListEntry.Kind.ALLOW ? "Allow" : "Deny") + " list, page " + page + " of " + pages + " (" + entries.size() + " entries):");
for (ListEntry entry : entries.subList((page - 1) * PAGE_SIZE, Math.min(entries.size(), page * PAGE_SIZE))) {
sender.reply(" " + entry.target() + " (by " + entry.addedBy() + ", " + expiry(entry.expiresAt())
+ (entry.note() == null ? "" : ", note: " + entry.note()) + ")");
}
});
}

public List<String> suggest(String[] args, Sender sender) {
List<String> options = new ArrayList<>();
if (args.length <= 1) {
if (sender.hasPermission(CHECK)) options.add("check");
if (sender.hasPermission(STATUS)) options.add("status");
if (sender.hasPermission(RELOAD)) options.add("reload");
if (sender.hasPermission(CACHE)) options.add("cache");
if (sender.hasPermission(ALLOW)) options.add("allow");
if (sender.hasPermission(DENY)) options.add("deny");
} else if (args.length == 2 && args[0].equalsIgnoreCase("check") && sender.hasPermission(CHECK)) {
options.addAll(platform.onlinePlayerNames());
} else if (args.length == 3 && args[0].equalsIgnoreCase("check") && sender.hasPermission(CHECK)) {
Expand All @@ -111,12 +308,24 @@ public List<String> suggest(String[] args, Sender sender) {
options.add("clear");
} else if (args.length == 3 && args[0].equalsIgnoreCase("cache") && sender.hasPermission(CACHE)) {
options.add("all");
} else if (kindOf(args[0]) != null && sender.hasPermission(permission(kindOf(args[0])))) {
suggestList(kindOf(args[0]), args, options);
}
String prefix = args.length == 0 ? "" : args[args.length - 1].toLowerCase(Locale.ROOT);
options.removeIf(option -> !option.toLowerCase(Locale.ROOT).startsWith(prefix));
return options;
}

private void suggestList(ListEntry.Kind kind, String[] args, List<String> options) {
if (args.length == 2) {
options.addAll(Arrays.asList("add", "remove", "list"));
} else if (args.length == 3 && args[1].equalsIgnoreCase("add")) {
options.addAll(platform.onlinePlayerNames());
} else if (args.length == 3 && args[1].equalsIgnoreCase("remove") && platform.runtime() != null) {
options.addAll(platform.runtime().lists().targets(kind));
}
}

private void check(String target, boolean refresh, Sender sender) {
OriginGateRuntime runtime = running(sender);
if (runtime == null) return;
Expand Down Expand Up @@ -220,5 +429,7 @@ private static void usage(Sender sender) {
if (sender.hasPermission(STATUS)) sender.reply(" /origingate status");
if (sender.hasPermission(RELOAD)) sender.reply(" /origingate reload");
if (sender.hasPermission(CACHE)) sender.reply(" /origingate cache clear <ip|all>");
if (sender.hasPermission(ALLOW)) sender.reply(" " + listUsage(ListEntry.Kind.ALLOW).substring("Usage: ".length()));
if (sender.hasPermission(DENY)) sender.reply(" " + listUsage(ListEntry.Kind.DENY).substring("Usage: ".length()));
}
}
Loading