3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00

Special case Keep Alive packets from Anti Xray

If a server enables Anti Xray, packet sending can be delayed until the
chunk has been obfuscated, blocking the entire queue from going out.

On a busy server, considering Anti Xray can only operate on a single
thread, it is quite possible the obfuscation backlog can get quite behind
resulting in a delay of sending packets.

And logging in is a clear area where lots of chunks are going to be queued
for obfuscation....

We should probably special case a few more than this (such as chat),
but this will hopefully help the keep alive issues some people run into.
Dieser Commit ist enthalten in:
Aikar 2020-05-02 00:53:57 -04:00
Ursprung a76b774070
Commit 5729bc716e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 401ADFC9891FAAFE
2 geänderte Dateien mit 25 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,4 @@
From d911fa59c930a36aa9c0ca24f9741fdedfecc6cb Mon Sep 17 00:00:00 2001
From dad171c74df2dc24940141bce47acdc433258603 Mon Sep 17 00:00:00 2001
From: willies952002 <admin@domnian.com>
Date: Mon, 28 Nov 2016 10:16:39 -0500
Subject: [PATCH] Allow Reloading of Command Aliases
@ -72,7 +72,7 @@ index adfc7aae2..460fda05a 100644
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
index c62da4131..af8ab73fe 100644
index c62da4131..0c7ba0718 100644
--- a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
@@ -13,7 +13,7 @@ public class ReloadCommand extends BukkitCommand {
@ -98,6 +98,14 @@ index c62da4131..af8ab73fe 100644
} else if ("confirm".equalsIgnoreCase(args[0])) {
confirmed = true;
} else {
@@ -53,6 +60,6 @@ public class ReloadCommand extends BukkitCommand {
@NotNull
@Override
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException {
- return java.util.Collections.singletonList("permissions"); // Paper
+ return com.google.common.collect.Lists.newArrayList("permissions", "commands"); // Paper
}
}
--
2.26.2

Datei anzeigen

@ -1,4 +1,4 @@
From bf95ae8ab5e6e73929fdf02bc049c33b55178c32 Mon Sep 17 00:00:00 2001
From f6be2f7be9bb53cabe1258d71f9dbc4ab92bcce6 Mon Sep 17 00:00:00 2001
From: stonar96 <minecraft.stonar96@gmail.com>
Date: Mon, 20 Aug 2018 03:03:58 +0200
Subject: [PATCH] Anti-Xray
@ -1377,30 +1377,22 @@ index 2c1d1b1a55..44aed67274 100644
if (this.h == this.b) {
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
index e156804f7a..96a785af27 100644
index ddc12364e7..0b6dce35e6 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -42,7 +42,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
return new DefaultEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Client IO #%d").setDaemon(true).build());
});
private final EnumProtocolDirection h;
- private final Queue<NetworkManager.QueuedPacket> packetQueue = Queues.newConcurrentLinkedQueue();
+ private final Queue<NetworkManager.QueuedPacket> packetQueue = Queues.newConcurrentLinkedQueue(); private final Queue<NetworkManager.QueuedPacket> getPacketQueue() { return this.packetQueue; } // Paper - OBFHELPER
public Channel channel;
public SocketAddress socketAddress; public void setSpoofedRemoteAddress(SocketAddress address) { this.socketAddress = address; } // Paper - OBFHELPER
// Spigot Start
@@ -164,8 +164,8 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
}
@@ -186,6 +186,11 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
public void sendPacket(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) {
- if (this.isConnected()) {
- this.o();
+ if (this.isConnected() && this.sendPacketQueue() && !(packet instanceof PacketPlayOutMapChunk && !((PacketPlayOutMapChunk) packet).isReady())) { // Paper - Async-Anti-Xray - Add chunk packets which are not ready or all packets if the packet queue contains chunk packets which are not ready to the packet queue and send the packets later in the right order
+ //this.o(); // Paper - Async-Anti-Xray - Move to if statement (this.sendPacketQueue())
this.b(packet, genericfuturelistener);
} else {
this.packetQueue.add(new NetworkManager.QueuedPacket(packet, genericfuturelistener));
@@ -223,21 +223,32 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
// Paper start start - handle oversized packets better
+ // Special case keepalive, allow it to go out of queue order
+ if (packet instanceof PacketPlayOutKeepAlive && this.isConnected()) {
+ this.dispatchPacket(packet, genericfuturelistener);
+ return;
+ }
// write the packets to the queue, then flush - antixray hooks there already
java.util.List<Packet> extraPackets = buildExtraPackets(packet);
boolean hasExtraPackets = extraPackets != null && !extraPackets.isEmpty();
@@ -248,21 +253,32 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
}
@ -1418,13 +1410,13 @@ index e156804f7a..96a785af27 100644
- while ((networkmanager_queuedpacket = (NetworkManager.QueuedPacket) this.packetQueue.poll()) != null) {
- this.b(networkmanager_queuedpacket.a, networkmanager_queuedpacket.b);
+ while (!this.packetQueue.isEmpty()) {
+ NetworkManager.QueuedPacket networkmanager_queuedpacket = (NetworkManager.QueuedPacket) this.getPacketQueue().peek(); // poll -> peek
+ NetworkManager.QueuedPacket networkmanager_queuedpacket = (NetworkManager.QueuedPacket) queue.peek(); // poll -> peek
+
+ if (networkmanager_queuedpacket != null) { // Fix NPE (Spigot bug caused by handleDisconnection())
+ if (networkmanager_queuedpacket.getPacket() instanceof PacketPlayOutMapChunk && !((PacketPlayOutMapChunk) networkmanager_queuedpacket.getPacket()).isReady()) { // Check if the peeked packet is a chunk packet which is not ready
+ return false; // Return false if the peeked packet is a chunk packet which is not ready
+ } else {
+ this.getPacketQueue().poll(); // poll here
+ queue.poll(); // poll here
+ this.dispatchPacket(networkmanager_queuedpacket.getPacket(), networkmanager_queuedpacket.getGenericFutureListener()); // dispatch the packet
+ }
+ }