From c67d91943ca9b87da3f31bcf6b92f462a8032990 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 24 Dec 2020 03:47:29 +0200 Subject: [PATCH 1/6] HAProxy PROXY protocol support for downstream connections (#1688) * Implement downstream PROXY protocol support * Clarify the configuration version updating procedure * Bump netty-resolver-dns to 4.1.56.Final * Update Netty to .56 * Don't increase jar size by 2MB Co-authored-by: Camotoy <20743703+Camotoy@users.noreply.github.com> --- connector/pom.xml | 20 +++++++++++++++---- .../configuration/GeyserConfiguration.java | 4 +++- .../GeyserJacksonConfiguration.java | 3 +++ .../network/session/GeyserSession.java | 5 +++++ connector/src/main/resources/config.yml | 5 +++++ 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/connector/pom.xml b/connector/pom.xml index b71fdcb6..ad34205e 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -124,14 +124,26 @@ 26201a4 compile - - io.netty - netty-all - net.kyori adventure-text-serializer-gson + + com.github.steveice10 + packetlib + + + + + com.github.steveice10 + PacketLib + 54f761c + compile + + + io.netty + netty-all + diff --git a/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java b/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java index dfa30ae9..a8044ef3 100644 --- a/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java +++ b/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java @@ -34,7 +34,7 @@ import java.util.Map; public interface GeyserConfiguration { - // Modify this when you update the config + // Modify this when you introduce breaking changes into the config int CURRENT_CONFIG_VERSION = 4; IBedrockConfiguration getBedrock(); @@ -117,6 +117,8 @@ public interface GeyserConfiguration { void setPort(int port); String getAuthType(); + + boolean isUseProxyProtocol(); } interface IUserAuthenticationInfo { diff --git a/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java b/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java index 67fa0449..c403bdf1 100644 --- a/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java +++ b/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java @@ -148,6 +148,9 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration @Setter @JsonProperty("auth-type") private String authType = "online"; + + @JsonProperty("use-proxy-protocol") + private boolean useProxyProtocol = false; } @Getter diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index 2e857cdd..ec383c44 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -39,6 +39,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlaye import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientTeleportConfirmPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.ServerRespawnPacket; import com.github.steveice10.mc.protocol.packet.login.server.LoginSuccessPacket; +import com.github.steveice10.packetlib.BuiltinFlags; import com.github.steveice10.packetlib.Client; import com.github.steveice10.packetlib.event.session.*; import com.github.steveice10.packetlib.packet.Packet; @@ -459,6 +460,10 @@ public class GeyserSession implements CommandSender { } downstream = new Client(remoteServer.getAddress(), remoteServer.getPort(), protocol, new TcpSessionFactory()); + if (connector.getConfig().getRemote().isUseProxyProtocol()) { + downstream.getSession().setFlag(BuiltinFlags.ENABLE_CLIENT_PROXY_PROTOCOL, true); + downstream.getSession().setFlag(BuiltinFlags.CLIENT_PROXIED_ADDRESS, upstream.getAddress()); + } // Let Geyser handle sending the keep alive downstream.getSession().setFlag(MinecraftConstants.AUTOMATIC_KEEP_ALIVE_MANAGEMENT, false); downstream.getSession().addListener(new SessionAdapter() { diff --git a/connector/src/main/resources/config.yml b/connector/src/main/resources/config.yml index bdb21216..ac9ec753 100644 --- a/connector/src/main/resources/config.yml +++ b/connector/src/main/resources/config.yml @@ -32,6 +32,11 @@ remote: port: 25565 # Authentication type. Can be offline, online, or floodgate (see https://github.com/GeyserMC/Geyser/wiki/Floodgate). auth-type: online + # Whether to enable PROXY protocol or not while connecting to the server. + # This is useful only when: + # 1) Your server supports PROXY protocol (it probably doesn't) + # 2) You run Velocity or BungeeCord with respective option enabled. + use-proxy-protocol: false # Floodgate uses encryption to ensure use from authorised sources. # This should point to the public key generated by Floodgate (Bungee or CraftBukkit) From eca626aad62f9eebf3d4d748a3ff120f9c69af6d Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 24 Dec 2020 07:31:23 +0200 Subject: [PATCH 2/6] Add missing netty-codec-haproxy dependency (#1731) --- connector/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/connector/pom.xml b/connector/pom.xml index ad34205e..f2133f02 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -152,6 +152,12 @@ 4.1.43.Final compile + + io.netty + netty-codec-haproxy + 4.1.56.Final + compile + org.reflections reflections From 9fc6228fc0793398b972967c479e9fa8d20dc5ec Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Thu, 24 Dec 2020 13:40:57 -0500 Subject: [PATCH 3/6] GeyserSession: remove 32 render distance cap (#1546) Having an incongruency between the server render distance and the client render distance appears to cause issues, and I have not been able to encounter such a crash. --- .../org/geysermc/connector/network/session/GeyserSession.java | 1 - 1 file changed, 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index ec383c44..33e25c13 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -653,7 +653,6 @@ public class GeyserSession implements CommandSender { public void setRenderDistance(int renderDistance) { renderDistance = GenericMath.ceil(++renderDistance * MathUtils.SQRT_OF_TWO); //square to circle - if (renderDistance > 32) renderDistance = 32; // <3 u ViaVersion but I don't like crashing clients x) this.renderDistance = renderDistance; ChunkRadiusUpdatedPacket chunkRadiusUpdatedPacket = new ChunkRadiusUpdatedPacket(); From eb5e4d79bb5ff22bb9fe944925aeea535243622f Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Sat, 26 Dec 2020 15:39:46 -0500 Subject: [PATCH 4/6] Add visual damage support with thorns (#1728) --- .../translators/java/entity/JavaEntityStatusTranslator.java | 1 + 1 file changed, 1 insertion(+) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityStatusTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityStatusTranslator.java index 5d7da284..6b76ea6d 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityStatusTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityStatusTranslator.java @@ -89,6 +89,7 @@ public class JavaEntityStatusTranslator extends PacketTranslator Date: Sat, 26 Dec 2020 21:40:49 +0100 Subject: [PATCH 5/6] Change Jenkins url and name to Open Collaboration (#1732) --- Jenkinsfile | 2 +- README.md | 2 +- .../org/geysermc/connector/command/defaults/VersionCommand.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7dfdaf30..e7f2ec4e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -66,7 +66,7 @@ pipeline { } deleteDir() withCredentials([string(credentialsId: 'geyser-discord-webhook', variable: 'DISCORD_WEBHOOK')]) { - discordSend description: "**Build:** [${currentBuild.id}](${env.BUILD_URL})\n**Status:** [${currentBuild.currentResult}](${env.BUILD_URL})\n${changes}\n\n[**Artifacts on Jenkins**](https://ci.nukkitx.com/job/Geyser)", footer: 'Cloudburst Jenkins', link: env.BUILD_URL, successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'), title: "${env.JOB_NAME} #${currentBuild.id}", webhookURL: DISCORD_WEBHOOK + discordSend description: "**Build:** [${currentBuild.id}](${env.BUILD_URL})\n**Status:** [${currentBuild.currentResult}](${env.BUILD_URL})\n${changes}\n\n[**Artifacts on Jenkins**](https://ci.opencollab.dev/job/GeyserMC/job/Geyser)", footer: 'Open Collaboration Jenkins', link: env.BUILD_URL, successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'), title: "${env.JOB_NAME} #${currentBuild.id}", webhookURL: DISCORD_WEBHOOK } } } diff --git a/README.md b/README.md index 4f6a6d43..816f765d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![forthebadge made-with-java](http://ForTheBadge.com/images/badges/made-with-java.svg)](https://java.com/) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) -[![Build Status](https://ci.nukkitx.com/job/Geyser/job/master/badge/icon)](https://ci.nukkitx.com/job/GeyserMC/job/Geyser/job/master/) +[![Build Status](https://ci.opencollab.dev/job/Geyser/job/master/badge/icon)](https://ci.opencollab.dev/job/GeyserMC/job/Geyser/job/master/) [![Discord](https://img.shields.io/discord/613163671870242838.svg?color=%237289da&label=discord)](http://discord.geysermc.org/) [![HitCount](http://hits.dwyl.io/Geyser/GeyserMC.svg)](http://hits.dwyl.io/Geyser/GeyserMC) [![Crowdin](https://badges.crowdin.net/geyser/localized.svg)](https://translate.geysermc.org/) diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/VersionCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/VersionCommand.java index 562bc9fb..88fab368 100644 --- a/connector/src/main/java/org/geysermc/connector/command/defaults/VersionCommand.java +++ b/connector/src/main/java/org/geysermc/connector/command/defaults/VersionCommand.java @@ -71,7 +71,7 @@ public class VersionCommand extends GeyserCommand { Properties gitProp = new Properties(); gitProp.load(FileUtils.getResource("git.properties")); - String buildXML = WebUtils.getBody("https://ci.nukkitx.com/job/GeyserMC/job/Geyser/job/" + URLEncoder.encode(gitProp.getProperty("git.branch"), StandardCharsets.UTF_8.toString()) + "/lastSuccessfulBuild/api/xml?xpath=//buildNumber"); + String buildXML = WebUtils.getBody("https://ci.opencollab.dev/job/GeyserMC/job/Geyser/job/" + URLEncoder.encode(gitProp.getProperty("git.branch"), StandardCharsets.UTF_8.toString()) + "/lastSuccessfulBuild/api/xml?xpath=//buildNumber"); if (buildXML.startsWith("")) { int latestBuildNum = Integer.parseInt(buildXML.replaceAll("<(\\\\)?(/)?buildNumber>", "").trim()); int buildNum = Integer.parseInt(gitProp.getProperty("git.build.number")); From d1c571d710ea2c14a606b6e224a76bebed967a84 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Sat, 26 Dec 2020 19:51:11 -0500 Subject: [PATCH 6/6] Fix anvil renaming (#1744) Turns out it *was* our fault. Oops. --- connector/pom.xml | 2 +- .../network/LoggingPacketHandler.java | 44 +++++++++++++++--- .../bedrock/BedrockFilterTextTranslator.java | 45 +++++++++++++++++++ 3 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockFilterTextTranslator.java diff --git a/connector/pom.xml b/connector/pom.xml index f2133f02..de095a33 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -32,7 +32,7 @@ com.github.CloudburstMC.Protocol bedrock-v422 - 87d862d69d + d41b84e86c compile diff --git a/connector/src/main/java/org/geysermc/connector/network/LoggingPacketHandler.java b/connector/src/main/java/org/geysermc/connector/network/LoggingPacketHandler.java index c41c64c7..c939f5b7 100644 --- a/connector/src/main/java/org/geysermc/connector/network/LoggingPacketHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/LoggingPacketHandler.java @@ -132,11 +132,6 @@ public class LoggingPacketHandler implements BedrockPacketHandler { return defaultHandler(packet); } - @Override - public boolean handle(EntityFallPacket packet) { - return defaultHandler(packet); - } - @Override public boolean handle(EntityPickRequestPacket packet) { return defaultHandler(packet); @@ -826,4 +821,43 @@ public class LoggingPacketHandler implements BedrockPacketHandler { public boolean handle(PositionTrackingDBServerBroadcastPacket packet) { return defaultHandler(packet); } + + // 1.16.100 new packets + + @Override + public boolean handle(MotionPredictionHintsPacket packet) { + return defaultHandler(packet); + } + + @Override + public boolean handle(AnimateEntityPacket packet) { + return defaultHandler(packet); + } + + @Override + public boolean handle(CameraShakePacket packet) { + return defaultHandler(packet); + } + + @Override + public boolean handle(PlayerFogPacket packet) { + return defaultHandler(packet); + } + + @Override + public boolean handle(CorrectPlayerMovePredictionPacket packet) { + return defaultHandler(packet); + } + + @Override + public boolean handle(ItemComponentPacket packet) { + return defaultHandler(packet); + } + + // 1.16.200 new packet + + @Override + public boolean handle(FilterTextPacket packet) { + return defaultHandler(packet); + } } \ No newline at end of file diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockFilterTextTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockFilterTextTranslator.java new file mode 100644 index 00000000..8c963076 --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockFilterTextTranslator.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Geyser + */ + +package org.geysermc.connector.network.translators.bedrock; + +import com.nukkitx.protocol.bedrock.packet.FilterTextPacket; +import org.geysermc.connector.network.session.GeyserSession; +import org.geysermc.connector.network.translators.PacketTranslator; +import org.geysermc.connector.network.translators.Translator; + +/** + * Used to send strings to the server and filter out unwanted words. + * Java doesn't care, so we don't care, and we approve all strings. + */ +@Translator(packet = FilterTextPacket.class) +public class BedrockFilterTextTranslator extends PacketTranslator { + + @Override + public void translate(FilterTextPacket packet, GeyserSession session) { + packet.setFromServer(true); + session.sendUpstreamPacket(packet); + } +}