Update to use protocol 589 and other 1.20 updates

This commit is contained in:
RednedEpic 2023-06-07 09:44:18 -05:00
parent 822568ecaa
commit 13c9063368
7 changed files with 31 additions and 13 deletions

View file

@ -6,7 +6,7 @@ plugins {
allprojects { allprojects {
group = "org.geysermc.geyser" group = "org.geysermc.geyser"
version = "2.1.0-SNAPSHOT" version = "2.1.1-SNAPSHOT"
description = "Allows for players from Minecraft: Bedrock Edition to join Minecraft: Java Edition servers." description = "Allows for players from Minecraft: Bedrock Edition to join Minecraft: Java Edition servers."
tasks.withType<JavaCompile> { tasks.withType<JavaCompile> {

View file

@ -29,7 +29,7 @@ import com.github.steveice10.mc.protocol.codec.MinecraftCodec;
import com.github.steveice10.mc.protocol.codec.PacketCodec; import com.github.steveice10.mc.protocol.codec.PacketCodec;
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec; import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
import org.cloudburstmc.protocol.bedrock.codec.v582.Bedrock_v582; import org.cloudburstmc.protocol.bedrock.codec.v582.Bedrock_v582;
import org.cloudburstmc.protocol.bedrock.codec.v588.Bedrock_v588; import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589;
import org.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec; import org.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
@ -45,7 +45,7 @@ public final class GameProtocol {
* Default Bedrock codec that should act as a fallback. Should represent the latest available * Default Bedrock codec that should act as a fallback. Should represent the latest available
* release of the game that Geyser supports. * release of the game that Geyser supports.
*/ */
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = Bedrock_v588.CODEC; public static final BedrockCodec DEFAULT_BEDROCK_CODEC = Bedrock_v589.CODEC;
/** /**
* A list of all supported Bedrock versions that can join Geyser * A list of all supported Bedrock versions that can join Geyser
@ -82,7 +82,7 @@ public final class GameProtocol {
/* Bedrock convenience methods to gatekeep features and easily remove the check on version removal */ /* Bedrock convenience methods to gatekeep features and easily remove the check on version removal */
public static boolean isPre1_20(GeyserSession session) { public static boolean isPre1_20(GeyserSession session) {
return session.getUpstream().getProtocolVersion() < Bedrock_v588.CODEC.getProtocolVersion(); return session.getUpstream().getProtocolVersion() < Bedrock_v589.CODEC.getProtocolVersion();
} }
/** /**

View file

@ -33,7 +33,7 @@ import com.google.common.collect.Interners;
import it.unimi.dsi.fastutil.objects.*; import it.unimi.dsi.fastutil.objects.*;
import org.cloudburstmc.nbt.*; import org.cloudburstmc.nbt.*;
import org.cloudburstmc.protocol.bedrock.codec.v582.Bedrock_v582; import org.cloudburstmc.protocol.bedrock.codec.v582.Bedrock_v582;
import org.cloudburstmc.protocol.bedrock.codec.v588.Bedrock_v588; import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589;
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition; import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.level.block.BlockStateValues; import org.geysermc.geyser.level.block.BlockStateValues;
@ -114,7 +114,7 @@ public final class BlockRegistryPopulator {
ImmutableMap<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> blockMappers = ImmutableMap.<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>>builder() ImmutableMap<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> blockMappers = ImmutableMap.<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>>builder()
.put(ObjectIntPair.of("1_19_80", Bedrock_v582.CODEC.getProtocolVersion()), legacyMapper) .put(ObjectIntPair.of("1_19_80", Bedrock_v582.CODEC.getProtocolVersion()), legacyMapper)
.put(ObjectIntPair.of("1_20_0", Bedrock_v588.CODEC.getProtocolVersion()), emptyMapper) .put(ObjectIntPair.of("1_20_0", Bedrock_v589.CODEC.getProtocolVersion()), emptyMapper)
.build(); .build();
// We can keep this strong as nothing should be garbage collected // We can keep this strong as nothing should be garbage collected

View file

@ -39,7 +39,7 @@ import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder; import org.cloudburstmc.nbt.NbtMapBuilder;
import org.cloudburstmc.nbt.NbtType; import org.cloudburstmc.nbt.NbtType;
import org.cloudburstmc.protocol.bedrock.codec.v582.Bedrock_v582; import org.cloudburstmc.protocol.bedrock.codec.v582.Bedrock_v582;
import org.cloudburstmc.protocol.bedrock.codec.v588.Bedrock_v588; import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589;
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition; import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition; import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
import org.cloudburstmc.protocol.bedrock.data.definitions.SimpleItemDefinition; import org.cloudburstmc.protocol.bedrock.data.definitions.SimpleItemDefinition;
@ -101,7 +101,7 @@ public class ItemRegistryPopulator {
return mapping; return mapping;
})); }));
paletteVersions.put("1_20_0", new PaletteVersion(Bedrock_v588.CODEC.getProtocolVersion())); paletteVersions.put("1_20_0", new PaletteVersion(Bedrock_v589.CODEC.getProtocolVersion()));
GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap(); GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap();

View file

@ -57,9 +57,11 @@ import javax.crypto.SecretKey;
import java.net.URI; import java.net.URI;
import java.security.KeyPair; import java.security.KeyPair;
import java.security.KeyPairGenerator; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey; import java.security.PublicKey;
import java.security.interfaces.ECPublicKey; import java.security.interfaces.ECPublicKey;
import java.security.spec.ECGenParameterSpec; import java.security.spec.ECGenParameterSpec;
import java.security.spec.InvalidKeySpecException;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -70,6 +72,18 @@ public class LoginEncryptionUtils {
private static boolean HAS_SENT_ENCRYPTION_MESSAGE = false; private static boolean HAS_SENT_ENCRYPTION_MESSAGE = false;
private static final ECPublicKey MOJANG_PUBLIC_KEY_OLD;
private static final ECPublicKey MOJANG_PUBLIC_KEY;
static {
try {
MOJANG_PUBLIC_KEY_OLD = EncryptionUtils.generateKey("MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V");
MOJANG_PUBLIC_KEY = EncryptionUtils.generateKey("MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAECRXueJeTDqNRRgJi/vlRufByu/2G0i2Ebt6YMar5QX/R0DIIyrJMcUpruK4QveTfJSTp3Shlq4Gk34cD/4GUWwkv0DVuzeuB+tXija7HBxii03NHDbPAD0AKnLr2wdAp");
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
throw new AssertionError("Unable to initialize required encryption", e);
}
}
private static boolean validateChainData(List<SignedJWT> chain) throws Exception { private static boolean validateChainData(List<SignedJWT> chain) throws Exception {
if (chain.size() != 3) { if (chain.size() != 3) {
return false; return false;
@ -105,7 +119,7 @@ public class LoginEncryptionUtils {
return !iterator.hasNext(); return !iterator.hasNext();
} }
if (lastKey.equals(EncryptionUtils.getMojangPublicKey())) { if (verifyMojangPublicKey(lastKey)) {
mojangSigned = true; mojangSigned = true;
} }
@ -120,6 +134,10 @@ public class LoginEncryptionUtils {
return mojangSigned; return mojangSigned;
} }
public static boolean verifyMojangPublicKey(ECPublicKey key) {
return MOJANG_PUBLIC_KEY.equals(key) || MOJANG_PUBLIC_KEY_OLD.equals(key);
}
public static void encryptPlayerConnection(GeyserSession session, LoginPacket loginPacket) { public static void encryptPlayerConnection(GeyserSession session, LoginPacket loginPacket) {
encryptConnectionWithCert(session, loginPacket.getExtra().getParsedString(), loginPacket.getChain()); encryptConnectionWithCert(session, loginPacket.getExtra().getParsedString(), loginPacket.getChain());
} }

View file

@ -5,7 +5,7 @@ org.gradle.caching=true
org.gradle.parallel=true org.gradle.parallel=true
group=org.geysermc group=org.geysermc
version=2.1.0-SNAPSHOT version=2.1.1-SNAPSHOT
org.gradle.caching=true org.gradle.caching=true
org.gradle.parallel=true org.gradle.parallel=true

View file

@ -9,11 +9,11 @@ netty = "4.1.80.Final"
guava = "29.0-jre" guava = "29.0-jre"
gson = "2.3.1" # Provided by Spigot 1.8.8 gson = "2.3.1" # Provided by Spigot 1.8.8
websocket = "1.5.1" websocket = "1.5.1"
protocol = "3.0.0.Beta1-20230522.135008-84" protocol = "3.0.0.Beta1-20230604.143616-86"
protocol-connection = "3.0.0.Beta1-20230522.135008-83" protocol-connection = "3.0.0.Beta1-20230604.143616-85"
raknet = "1.0.0.CR1-20230430.211932-7" raknet = "1.0.0.CR1-20230430.211932-7"
mcauthlib = "d9d773e" mcauthlib = "d9d773e"
mcprotocollib = "1.20-1-SNAPSHOT" mcprotocollib = "1.20-1-20230607.135651-6" # Temporary hack - needs to be updated to release once publishing is fixed
adventure = "4.14.0-20230424.215040-7" adventure = "4.14.0-20230424.215040-7"
adventure-platform = "4.1.2" adventure-platform = "4.1.2"
junit = "5.9.2" junit = "5.9.2"