Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-03 14:50:19 +01:00
Merge branch 'floodgate-2.0' of https://github.com/GeyserMC/Geyser into floodgate-2.0
Dieser Commit ist enthalten in:
Commit
53ac196b61
@ -29,6 +29,7 @@ package org.geysermc.floodgate.crypto;
|
|||||||
import javax.crypto.KeyGenerator;
|
import javax.crypto.KeyGenerator;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
public final class AesKeyProducer implements KeyProducer {
|
public final class AesKeyProducer implements KeyProducer {
|
||||||
@ -38,7 +39,7 @@ public final class AesKeyProducer implements KeyProducer {
|
|||||||
public SecretKey produce() {
|
public SecretKey produce() {
|
||||||
try {
|
try {
|
||||||
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
|
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
|
||||||
keyGenerator.init(KEY_SIZE, SecureRandom.getInstanceStrong());
|
keyGenerator.init(KEY_SIZE, getSecureRandom());
|
||||||
return keyGenerator.generateKey();
|
return keyGenerator.generateKey();
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
throw new RuntimeException(exception);
|
throw new RuntimeException(exception);
|
||||||
@ -53,4 +54,21 @@ public final class AesKeyProducer implements KeyProducer {
|
|||||||
throw new RuntimeException(exception);
|
throw new RuntimeException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SecureRandom getSecureRandom() throws NoSuchAlgorithmException {
|
||||||
|
// use Windows-PRNG for windows (default impl is SHA1PRNG)
|
||||||
|
if (System.getProperty("os.name").startsWith("Windows")) {
|
||||||
|
return SecureRandom.getInstance("Windows-PRNG");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
// NativePRNG (which should be the default on unix-systems) can still block your
|
||||||
|
// system. Even though it isn't as bad as NativePRNGBlocking, we still try to
|
||||||
|
// prevent that if possible
|
||||||
|
return SecureRandom.getInstance("NativePRNGNonBlocking");
|
||||||
|
} catch (NoSuchAlgorithmException ignored) {
|
||||||
|
// at this point we just have to go with the default impl even if it blocks
|
||||||
|
return new SecureRandom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,9 +101,8 @@ public final class BedrockData implements Cloneable {
|
|||||||
// The format is the same as the order of the fields in this class
|
// The format is the same as the order of the fields in this class
|
||||||
return version + '\0' + username + '\0' + xuid + '\0' + deviceOs + '\0' +
|
return version + '\0' + username + '\0' + xuid + '\0' + deviceOs + '\0' +
|
||||||
languageCode + '\0' + uiProfile + '\0' + inputMode + '\0' + ip + '\0' +
|
languageCode + '\0' + uiProfile + '\0' + inputMode + '\0' + ip + '\0' +
|
||||||
(fromProxy ? 1 : 0) + '\0' +
|
|
||||||
(linkedPlayer != null ? linkedPlayer.toString() : "null") + '\0' +
|
(linkedPlayer != null ? linkedPlayer.toString() : "null") + '\0' +
|
||||||
subscribeId + '\0' + verifyCode + '\0' + timestamp;
|
(fromProxy ? 1 : 0) + '\0' + subscribeId + '\0' + verifyCode + '\0' + timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,6 +39,7 @@ import org.geysermc.floodgate.util.WebsocketEventType;
|
|||||||
import org.java_websocket.client.WebSocketClient;
|
import org.java_websocket.client.WebSocketClient;
|
||||||
import org.java_websocket.handshake.ServerHandshake;
|
import org.java_websocket.handshake.ServerHandshake;
|
||||||
|
|
||||||
|
import javax.net.ssl.SSLException;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -161,9 +162,13 @@ public final class FloodgateSkinUploader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception ex) {
|
public void onError(Exception ex) {
|
||||||
if (!(ex instanceof ConnectException)) {
|
if (ex instanceof ConnectException || ex instanceof SSLException) {
|
||||||
logger.error("Got an error", ex);
|
if (logger.isDebug()) {
|
||||||
|
logger.error("[debug] Got an error", ex);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
logger.error("Got an error", ex);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren