mirror of
https://github.com/PaperMC/Velocity
synced 2026-08-18 22:23:06 -04:00
Setup encryption before possible disconnect (#1754)
This commit is contained in:
parent
729a050662
commit
b8d1f16b07
1 changed files with 5 additions and 13 deletions
|
|
@ -200,8 +200,12 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
|
|||
}
|
||||
|
||||
byte[] decryptedSharedSecret = decryptRsa(serverKeyPair, packet.getSharedSecret());
|
||||
String serverId = generateServerId(decryptedSharedSecret, serverKeyPair.getPublic());
|
||||
|
||||
// Go ahead and enable encryption. Once the client sends EncryptionResponse, encryption
|
||||
// is enabled.
|
||||
mcConnection.enableEncryption(decryptedSharedSecret);
|
||||
|
||||
String serverId = generateServerId(decryptedSharedSecret, serverKeyPair.getPublic());
|
||||
String playerIp = ((InetSocketAddress) mcConnection.getRemoteAddress()).getHostString();
|
||||
String url = String.format(MOJANG_HASJOINED_URL,
|
||||
urlFormParameterEscaper().escape(login.getUsername()), serverId);
|
||||
|
|
@ -230,18 +234,6 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
// Go ahead and enable encryption. Once the client sends EncryptionResponse, encryption
|
||||
// is enabled.
|
||||
try {
|
||||
mcConnection.enableEncryption(decryptedSharedSecret);
|
||||
} catch (GeneralSecurityException e) {
|
||||
logger.error("Unable to enable encryption for connection", e);
|
||||
// At this point, the connection is encrypted, but something's wrong on our side and
|
||||
// we can't do anything about it.
|
||||
mcConnection.close(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.statusCode() == 200) {
|
||||
final GameProfile profile = GENERAL_GSON.fromJson(response.body(),
|
||||
GameProfile.class);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue