From 13c906336894d171c8f75e3bfe5e7d6a2fa6cd78 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Wed, 7 Jun 2023 09:44:18 -0500 Subject: [PATCH] Update to use protocol 589 and other 1.20 updates --- build.gradle.kts | 2 +- .../geysermc/geyser/network/GameProtocol.java | 6 +++--- .../populator/BlockRegistryPopulator.java | 4 ++-- .../populator/ItemRegistryPopulator.java | 4 ++-- .../geyser/util/LoginEncryptionUtils.java | 20 ++++++++++++++++++- gradle.properties | 2 +- gradle/libs.versions.toml | 6 +++--- 7 files changed, 31 insertions(+), 13 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4304811ff..c64667ad2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { allprojects { 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." tasks.withType { diff --git a/core/src/main/java/org/geysermc/geyser/network/GameProtocol.java b/core/src/main/java/org/geysermc/geyser/network/GameProtocol.java index 63a235cfc..d4ab2f42e 100644 --- a/core/src/main/java/org/geysermc/geyser/network/GameProtocol.java +++ b/core/src/main/java/org/geysermc/geyser/network/GameProtocol.java @@ -29,7 +29,7 @@ import com.github.steveice10.mc.protocol.codec.MinecraftCodec; import com.github.steveice10.mc.protocol.codec.PacketCodec; import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec; 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.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 * 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 @@ -82,7 +82,7 @@ public final class GameProtocol { /* Bedrock convenience methods to gatekeep features and easily remove the check on version removal */ public static boolean isPre1_20(GeyserSession session) { - return session.getUpstream().getProtocolVersion() < Bedrock_v588.CODEC.getProtocolVersion(); + return session.getUpstream().getProtocolVersion() < Bedrock_v589.CODEC.getProtocolVersion(); } /** diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java index 82c933d94..10e6d808b 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java @@ -33,7 +33,7 @@ import com.google.common.collect.Interners; import it.unimi.dsi.fastutil.objects.*; import org.cloudburstmc.nbt.*; 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.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.level.block.BlockStateValues; @@ -114,7 +114,7 @@ public final class BlockRegistryPopulator { ImmutableMap, BiFunction> blockMappers = ImmutableMap., BiFunction>builder() .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(); // We can keep this strong as nothing should be garbage collected diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java index 8f7e18dbb..d4cef1035 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java @@ -39,7 +39,7 @@ import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtMapBuilder; import org.cloudburstmc.nbt.NbtType; 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.ItemDefinition; import org.cloudburstmc.protocol.bedrock.data.definitions.SimpleItemDefinition; @@ -101,7 +101,7 @@ public class ItemRegistryPopulator { 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(); diff --git a/core/src/main/java/org/geysermc/geyser/util/LoginEncryptionUtils.java b/core/src/main/java/org/geysermc/geyser/util/LoginEncryptionUtils.java index dd523df5a..9d7c8d5a4 100644 --- a/core/src/main/java/org/geysermc/geyser/util/LoginEncryptionUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/LoginEncryptionUtils.java @@ -57,9 +57,11 @@ import javax.crypto.SecretKey; import java.net.URI; import java.security.KeyPair; import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; import java.security.PublicKey; import java.security.interfaces.ECPublicKey; import java.security.spec.ECGenParameterSpec; +import java.security.spec.InvalidKeySpecException; import java.util.Iterator; import java.util.List; import java.util.UUID; @@ -70,6 +72,18 @@ public class LoginEncryptionUtils { 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 chain) throws Exception { if (chain.size() != 3) { return false; @@ -105,7 +119,7 @@ public class LoginEncryptionUtils { return !iterator.hasNext(); } - if (lastKey.equals(EncryptionUtils.getMojangPublicKey())) { + if (verifyMojangPublicKey(lastKey)) { mojangSigned = true; } @@ -120,6 +134,10 @@ public class LoginEncryptionUtils { 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) { encryptConnectionWithCert(session, loginPacket.getExtra().getParsedString(), loginPacket.getChain()); } diff --git a/gradle.properties b/gradle.properties index 4fb72e2fc..f19b65876 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.caching=true org.gradle.parallel=true group=org.geysermc -version=2.1.0-SNAPSHOT +version=2.1.1-SNAPSHOT org.gradle.caching=true org.gradle.parallel=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 35eef0982..f0ff72923 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,11 +9,11 @@ netty = "4.1.80.Final" guava = "29.0-jre" gson = "2.3.1" # Provided by Spigot 1.8.8 websocket = "1.5.1" -protocol = "3.0.0.Beta1-20230522.135008-84" -protocol-connection = "3.0.0.Beta1-20230522.135008-83" +protocol = "3.0.0.Beta1-20230604.143616-86" +protocol-connection = "3.0.0.Beta1-20230604.143616-85" raknet = "1.0.0.CR1-20230430.211932-7" 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-platform = "4.1.2" junit = "5.9.2"