mirror of https://github.com/LOOHP/Limbo.git
change allowlist implementation to HashMap & don't leak the implementation outside of the ServerProperties class
This commit is contained in:
parent
2c2285b54c
commit
a797e89c14
|
|
@ -442,13 +442,11 @@ public class Limbo {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (UUID allowedUuid : properties.getAllowlist()) {
|
if (properties.uuidIsAllowed(requestedUuid)) {
|
||||||
if (requestedUuid.equals(allowedUuid)) {
|
if(!properties.isReducedDebugInfo()) {
|
||||||
if(!properties.isReducedDebugInfo()) {
|
Limbo.getInstance().getConsole().sendMessage(String.format("allowlist: %s allowed", requestedUuid.toString()));
|
||||||
Limbo.getInstance().getConsole().sendMessage(String.format("allowlist: %s allowed", requestedUuid.toString()));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!properties.isReducedDebugInfo()) {
|
if(!properties.isReducedDebugInfo()) {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import java.io.OutputStreamWriter;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
@ -84,7 +85,7 @@ public class ServerProperties {
|
||||||
private double ticksPerSecond;
|
private double ticksPerSecond;
|
||||||
private boolean handshakeVerbose;
|
private boolean handshakeVerbose;
|
||||||
private boolean enforceAllowlist;
|
private boolean enforceAllowlist;
|
||||||
private ArrayList<UUID> allowlist;
|
private HashMap<UUID, Boolean> allowlist;
|
||||||
|
|
||||||
private String resourcePackSHA1;
|
private String resourcePackSHA1;
|
||||||
private String resourcePackLink;
|
private String resourcePackLink;
|
||||||
|
|
@ -208,7 +209,7 @@ public class ServerProperties {
|
||||||
public void reloadAllowlist() {
|
public void reloadAllowlist() {
|
||||||
Console console = Limbo.getInstance().getConsole();
|
Console console = Limbo.getInstance().getConsole();
|
||||||
|
|
||||||
allowlist = new ArrayList<UUID>();
|
allowlist = new HashMap<UUID, Boolean>();
|
||||||
try {
|
try {
|
||||||
JSONParser parser = new JSONParser();
|
JSONParser parser = new JSONParser();
|
||||||
Object obj = parser.parse(new FileReader("allowlist.json"));
|
Object obj = parser.parse(new FileReader("allowlist.json"));
|
||||||
|
|
@ -241,7 +242,7 @@ public class ServerProperties {
|
||||||
|
|
||||||
String uuidStr = (String) o;
|
String uuidStr = (String) o;
|
||||||
UUID allowedUuid = UUID.fromString(uuidStr);
|
UUID allowedUuid = UUID.fromString(uuidStr);
|
||||||
allowlist.add(allowedUuid);
|
allowlist.put(allowedUuid, true);
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
console.sendMessage(e.toString());
|
console.sendMessage(e.toString());
|
||||||
|
|
@ -368,8 +369,11 @@ public class ServerProperties {
|
||||||
return enforceAllowlist;
|
return enforceAllowlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<UUID> getAllowlist() {
|
public boolean uuidIsAllowed(UUID requestedUuid) {
|
||||||
return allowlist;
|
if (allowlist.containsKey(requestedUuid)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResourcePackLink() {
|
public String getResourcePackLink() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue