Perform equality check

This commit is contained in:
games647
2022-07-28 13:25:13 +02:00
parent 5af43170da
commit fd33523189
2 changed files with 14 additions and 3 deletions

View File

@@ -50,6 +50,7 @@ import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.SignatureException;
import java.time.Instant;
import java.util.Objects;
import java.util.Optional;
import javax.crypto.BadPaddingException;
@@ -75,6 +76,8 @@ public class ProtocolLibListener extends PacketAdapter {
private final boolean verifyClientKeys;
private PacketContainer lastStartPacket;
public ProtocolLibListener(FastLoginBukkit plugin, AntiBotService antiBotService, boolean verifyClientKeys) {
//run async in order to not block the server, because we are making api calls to Mojang
super(params()
@@ -95,11 +98,19 @@ public class ProtocolLibListener extends PacketAdapter {
@Override
public void onPacketReceiving(PacketEvent packetEvent) {
PacketContainer packet = packetEvent.getPacket();
plugin.getLog().info("New packet {} from {}; Cancellation: {}, Meta: {}",
packetEvent.getPacketType(), packetEvent.getPlayer(), packetEvent.isCancelled(),
packetEvent.getPacket().getMeta(SOURCE_META_KEY)
packet.getMeta(SOURCE_META_KEY)
);
if (packetEvent.getPacketType() == START) {
plugin.getLog().info("Start-packet equality (Last/New): {}/{}, {}",
lastStartPacket.hashCode(), packet.hashCode(), Objects.equals(lastStartPacket, packet)
);
lastStartPacket = packet;
}
if (packetEvent.isCancelled()
|| plugin.getCore().getAuthPluginHook() == null
|| !plugin.isServerFullyStarted()) {
@@ -114,7 +125,7 @@ public class ProtocolLibListener extends PacketAdapter {
Player sender = packetEvent.getPlayer();
PacketType packetType = packetEvent.getPacketType();
if (packetType == START) {
PacketContainer packet = packetEvent.getPacket();
// PacketContainer packet = packet;
InetSocketAddress address = sender.getAddress();
String username = getUsername(packet);

View File

@@ -289,7 +289,7 @@ public class VerifyResponseTask implements Runnable {
//we don't want to handle our own packets so ignore filters
startPacket.setMeta(ProtocolLibListener.SOURCE_META_KEY, plugin.getName());
ProtocolLibrary.getProtocolManager().receiveClientPacket(player, startPacket, false);
ProtocolLibrary.getProtocolManager().receiveClientPacket(player, startPacket, true);
plugin.getLog().info("Sending new fake login start packet to {}-{}", player, username);
}
}