forked from TuxCoding/FastLogin
Perform equality check
This commit is contained in:
@@ -50,6 +50,7 @@ import java.security.PublicKey;
|
|||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.security.SignatureException;
|
import java.security.SignatureException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.BadPaddingException;
|
||||||
@@ -75,6 +76,8 @@ public class ProtocolLibListener extends PacketAdapter {
|
|||||||
|
|
||||||
private final boolean verifyClientKeys;
|
private final boolean verifyClientKeys;
|
||||||
|
|
||||||
|
private PacketContainer lastStartPacket;
|
||||||
|
|
||||||
public ProtocolLibListener(FastLoginBukkit plugin, AntiBotService antiBotService, boolean verifyClientKeys) {
|
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
|
//run async in order to not block the server, because we are making api calls to Mojang
|
||||||
super(params()
|
super(params()
|
||||||
@@ -95,11 +98,19 @@ public class ProtocolLibListener extends PacketAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent packetEvent) {
|
public void onPacketReceiving(PacketEvent packetEvent) {
|
||||||
|
PacketContainer packet = packetEvent.getPacket();
|
||||||
plugin.getLog().info("New packet {} from {}; Cancellation: {}, Meta: {}",
|
plugin.getLog().info("New packet {} from {}; Cancellation: {}, Meta: {}",
|
||||||
packetEvent.getPacketType(), packetEvent.getPlayer(), packetEvent.isCancelled(),
|
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()
|
if (packetEvent.isCancelled()
|
||||||
|| plugin.getCore().getAuthPluginHook() == null
|
|| plugin.getCore().getAuthPluginHook() == null
|
||||||
|| !plugin.isServerFullyStarted()) {
|
|| !plugin.isServerFullyStarted()) {
|
||||||
@@ -114,7 +125,7 @@ public class ProtocolLibListener extends PacketAdapter {
|
|||||||
Player sender = packetEvent.getPlayer();
|
Player sender = packetEvent.getPlayer();
|
||||||
PacketType packetType = packetEvent.getPacketType();
|
PacketType packetType = packetEvent.getPacketType();
|
||||||
if (packetType == START) {
|
if (packetType == START) {
|
||||||
PacketContainer packet = packetEvent.getPacket();
|
// PacketContainer packet = packet;
|
||||||
|
|
||||||
InetSocketAddress address = sender.getAddress();
|
InetSocketAddress address = sender.getAddress();
|
||||||
String username = getUsername(packet);
|
String username = getUsername(packet);
|
||||||
|
@@ -289,7 +289,7 @@ public class VerifyResponseTask implements Runnable {
|
|||||||
|
|
||||||
//we don't want to handle our own packets so ignore filters
|
//we don't want to handle our own packets so ignore filters
|
||||||
startPacket.setMeta(ProtocolLibListener.SOURCE_META_KEY, plugin.getName());
|
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);
|
plugin.getLog().info("Sending new fake login start packet to {}-{}", player, username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user