mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 10:47:33 +02:00
@ -179,7 +179,8 @@ public class ProtocolLibListener extends PacketAdapter {
|
|||||||
private boolean verifyNonce(Player sender, PacketContainer packet,
|
private boolean verifyNonce(Player sender, PacketContainer packet,
|
||||||
ClientPublicKey clientPublicKey, byte[] expectedToken) {
|
ClientPublicKey clientPublicKey, byte[] expectedToken) {
|
||||||
try {
|
try {
|
||||||
if (MinecraftVersion.atOrAbove(new MinecraftVersion(1, 19, 0))) {
|
if (MinecraftVersion.atOrAbove(new MinecraftVersion(1, 19, 0))
|
||||||
|
&& !MinecraftVersion.atOrAbove(new MinecraftVersion(1, 19, 3))) {
|
||||||
Either<byte[], ?> either = packet.getSpecificModifier(Either.class).read(0);
|
Either<byte[], ?> either = packet.getSpecificModifier(Either.class).read(0);
|
||||||
if (clientPublicKey == null) {
|
if (clientPublicKey == null) {
|
||||||
Optional<byte[]> left = either.left();
|
Optional<byte[]> left = either.left();
|
||||||
@ -222,27 +223,34 @@ public class ProtocolLibListener extends PacketAdapter {
|
|||||||
plugin.removeSession(player.getAddress());
|
plugin.removeSession(player.getAddress());
|
||||||
|
|
||||||
PacketContainer packet = packetEvent.getPacket();
|
PacketContainer packet = packetEvent.getPacket();
|
||||||
val profileKey = packet.getOptionals(BukkitConverters.getWrappedPublicKeyDataConverter())
|
Optional<ClientPublicKey> clientKey = Optional.empty();
|
||||||
.optionRead(0);
|
if (MinecraftVersion.atOrAbove(new MinecraftVersion(1, 19, 3))) {
|
||||||
|
// public key sent separate
|
||||||
|
clientKey = Optional.empty();
|
||||||
|
} else {
|
||||||
|
val profileKey = packet.getOptionals(BukkitConverters.getWrappedPublicKeyDataConverter())
|
||||||
|
.optionRead(0);
|
||||||
|
|
||||||
val clientKey = profileKey.flatMap(Function.identity()).flatMap(data -> {
|
clientKey = profileKey.flatMap(Function.identity()).flatMap(data -> {
|
||||||
Instant expires = data.getExpireTime();
|
Instant expires = data.getExpireTime();
|
||||||
PublicKey key = data.getKey();
|
PublicKey key = data.getKey();
|
||||||
byte[] signature = data.getSignature();
|
byte[] signature = data.getSignature();
|
||||||
return Optional.of(ClientPublicKey.of(expires, key, signature));
|
return Optional.of(ClientPublicKey.of(expires, key, signature));
|
||||||
});
|
});
|
||||||
|
|
||||||
// start reading from index 1, because 0 is already used by the public key
|
// start reading from index 1, because 0 is already used by the public key
|
||||||
Optional<UUID> sessionUUID = packet.getOptionals(Converters.passthrough(UUID.class)).readSafely(1);
|
Optional<UUID> sessionUUID = packet.getOptionals(Converters.passthrough(UUID.class)).readSafely(1);
|
||||||
if (verifyClientKeys && sessionUUID.isPresent() && clientKey.isPresent()
|
if (verifyClientKeys && sessionUUID.isPresent() && clientKey.isPresent()
|
||||||
&& verifyPublicKey(clientKey.get(), sessionUUID.get())) {
|
&& verifyPublicKey(clientKey.get(), sessionUUID.get())) {
|
||||||
// missing or incorrect
|
// missing or incorrect
|
||||||
// expired always not allowed
|
// expired always not allowed
|
||||||
player.kickPlayer(plugin.getCore().getMessage("invalid-public-key"));
|
player.kickPlayer(plugin.getCore().getMessage("invalid-public-key"));
|
||||||
plugin.getLog().warn("Invalid public key from player {}", username);
|
plugin.getLog().warn("Invalid public key from player {}", username);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
plugin.getLog().trace("GameProfile {} with {} connecting", sessionKey, username);
|
plugin.getLog().trace("GameProfile {} with {} connecting", sessionKey, username);
|
||||||
|
|
||||||
packetEvent.getAsyncMarker().incrementProcessingDelay();
|
packetEvent.getAsyncMarker().incrementProcessingDelay();
|
||||||
|
Reference in New Issue
Block a user