fix eagler packets not working on newer protocolsupports

This commit is contained in:
ayunami2000 2022-07-05 18:24:27 -04:00
parent ab7690f366
commit 5644655282
4 changed files with 9 additions and 2 deletions

View File

@ -28,6 +28,8 @@ public class Main {
public static boolean forwarded = false;
public static boolean eaglerPackets = false;
public static WebSocketServer webSocketServer = null;
public static Map<WebSocket, Client> clients = new HashMap<>();
@ -110,6 +112,7 @@ public class Main {
port = (int) config.getOrDefault("port", 25569);
webPort = (int) config.getOrDefault("web_port", 25565);
forwarded = (boolean) config.getOrDefault("forwarded", false);
eaglerPackets = (boolean) config.getOrDefault("eag_packets", false);
List<String> defaultMotd = new ArrayList<>();

View File

@ -139,12 +139,14 @@ public class WebSocketProxy extends WebSocketServer {
return;
}
}
byte[] packet = message.array();
if (!Main.eaglerPackets && packet.length >= 11 && packet[0] == -6 && packet[2] >= 4 && packet[4] == 69 && packet[6] == 65 && packet[8] == 71 && packet[10] == 124) return; // EAG|
Client currClient = Main.clients.get(conn);
if (currClient.socketOut == null) {
currClient.msgCache.add(message.array());
currClient.msgCache.add(packet);
} else if (!currClient.socket.isOutputShutdown()) {
try {
currClient.socketOut.write(message.array());
currClient.socketOut.write(packet);
} catch (IOException ignored) {}
}
}

View File

@ -6,6 +6,8 @@ port: 25569
web_port: 25565
# if this is behind a reverse proxy, such as caddy or nginx. uses X-Real-IP header.
forwarded: false
# forward eagler-specific packets?
eag_packets: false
# origin blacklist URL (leave empty to disable syncing)
origin_blacklist: "https://g.eags.us/eaglercraft/origin_blacklist.txt"
# whitelisted origins -- if specified, only allows the listed origins to connect