Flesh out allowlist handling

Addresses comments from https://github.com/LOOHP/Limbo/pull/57#issuecomment-1304543589

In particular:

* Functionality now matches other server types

* only enforce the allowlist if a new "enforce-allowlist"
  boolean in server.properties is set to true

* Loads and process the allowlist only once when the server starts (or
  the reload command is executed), instead of every time a user connects.

* Add a new command & associated permissions "allowlist reload"
  to reload the allowlist
This commit is contained in:
Tad Hunt
2022-11-05 14:32:25 -06:00
parent 898fe20b14
commit d3b0aba94f
4 changed files with 118 additions and 85 deletions
+25
View File
@@ -432,6 +432,31 @@ public class Limbo {
public ServerProperties getServerProperties() {
return properties;
}
public void reloadAllowlist() {
properties.reloadAllowlist();
}
public boolean uuidIsAllowed(UUID requestedUuid) {
if (!properties.isEnforceAllowlist()) {
return true;
}
for (UUID allowedUuid : properties.getAllowlist()) {
if (requestedUuid.equals(allowedUuid)) {
if(!properties.isReducedDebugInfo()) {
Limbo.getInstance().getConsole().sendMessage(String.format("allowlist: %s allowed", requestedUuid.toString()));
}
return true;
}
}
if(!properties.isReducedDebugInfo()) {
Limbo.getInstance().getConsole().sendMessage(String.format("allowlist: %s not allowed", requestedUuid.toString()));
}
return false;
}
public ServerConnection getServerConnection() {
return server;