3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-25 15:50:14 +01:00

Allow connections even if encryption failed to initialize post-1.16.220 (#2147)

This allows Java 16 to still be compatible with Geyser.
Dieser Commit ist enthalten in:
Camotoy 2021-05-02 13:07:04 -04:00 committet von GitHub
Ursprung 1301cd9c30
Commit e74fa6c42d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
3 geänderte Dateien mit 24 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -32,7 +32,7 @@
<dependency> <dependency>
<groupId>com.github.CloudburstMC.Protocol</groupId> <groupId>com.github.CloudburstMC.Protocol</groupId>
<artifactId>bedrock-v431</artifactId> <artifactId>bedrock-v431</artifactId>
<version>f8ecf54</version> <version>9947665</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>

Datei anzeigen

@ -60,6 +60,8 @@ import java.util.UUID;
public class LoginEncryptionUtils { public class LoginEncryptionUtils {
private static final ObjectMapper JSON_MAPPER = new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); private static final ObjectMapper JSON_MAPPER = new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
private static boolean HAS_SENT_ENCRYPTION_MESSAGE = false;
private static boolean validateChainData(JsonNode data) throws Exception { private static boolean validateChainData(JsonNode data) throws Exception {
ECPublicKey lastKey = null; ECPublicKey lastKey = null;
boolean validChain = false; boolean validChain = false;
@ -133,7 +135,18 @@ public class LoginEncryptionUtils {
session.setClientData(JSON_MAPPER.convertValue(JSON_MAPPER.readTree(clientJwt.getPayload().toBytes()), BedrockClientData.class)); session.setClientData(JSON_MAPPER.convertValue(JSON_MAPPER.readTree(clientJwt.getPayload().toBytes()), BedrockClientData.class));
if (EncryptionUtils.canUseEncryption()) { if (EncryptionUtils.canUseEncryption()) {
LoginEncryptionUtils.startEncryptionHandshake(session, identityPublicKey); try {
LoginEncryptionUtils.startEncryptionHandshake(session, identityPublicKey);
} catch (Throwable e) {
// An error can be thrown on older Java 8 versions about an invalid key
if (connector.getConfig().isDebugMode()) {
e.printStackTrace();
}
sendEncryptionFailedMessage(connector);
}
} else {
sendEncryptionFailedMessage(connector);
} }
} catch (Exception ex) { } catch (Exception ex) {
session.disconnect("disconnectionScreen.internalError.cantConnect"); session.disconnect("disconnectionScreen.internalError.cantConnect");
@ -155,6 +168,14 @@ public class LoginEncryptionUtils {
session.sendUpstreamPacketImmediately(packet); session.sendUpstreamPacketImmediately(packet);
} }
private static void sendEncryptionFailedMessage(GeyserConnector connector) {
if (!HAS_SENT_ENCRYPTION_MESSAGE) {
connector.getLogger().warning(LanguageUtils.getLocaleStringLog("geyser.network.encryption.line_1"));
connector.getLogger().warning(LanguageUtils.getLocaleStringLog("geyser.network.encryption.line_2", "https://geysermc.org/supported_java"));
HAS_SENT_ENCRYPTION_MESSAGE = true;
}
}
private static final int AUTH_MSA_DETAILS_FORM_ID = 1334; private static final int AUTH_MSA_DETAILS_FORM_ID = 1334;
private static final int AUTH_MSA_CODE_FORM_ID = 1335; private static final int AUTH_MSA_CODE_FORM_ID = 1335;
private static final int AUTH_FORM_ID = 1336; private static final int AUTH_FORM_ID = 1336;

@ -1 +1 @@
Subproject commit 3d3b60de724f3f552f351c5f400269fde7598b67 Subproject commit 96e7ed66ccdafea0cc991b8004566d448e8f6e6a