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

Warn if we were unable to check if the system clock is accurate

Dieser Commit ist enthalten in:
Tim203 2021-05-26 20:20:59 +02:00
Ursprung 776fc4e933
Commit 934fc12b16
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 064EE9F5BF7C3EE8
3 geänderte Dateien mit 21 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -37,7 +37,7 @@ public final class TimeSyncer {
public TimeSyncer(String timeServer) {
ScheduledExecutorService service = Executors.newScheduledThreadPool(1);
service.scheduleWithFixedDelay(() -> {
// 5 tries to get the time offset
// 5 tries to get the time offset, since UDP doesn't guaranty a response
for (int i = 0; i < 5; i++) {
long offset = SntpClientUtils.requestTimeOffset(timeServer, 3000);
if (offset != Long.MIN_VALUE) {
@ -56,4 +56,15 @@ public final class TimeSyncer {
public long getTimeOffset() {
return timeOffset;
}
public long getRealMillis() {
if (hasUsefulOffset()) {
return System.currentTimeMillis() + getTimeOffset();
}
return System.currentTimeMillis();
}
public boolean hasUsefulOffset() {
return timeOffset != Long.MIN_VALUE;
}
}

Datei anzeigen

@ -62,15 +62,9 @@ public final class BedrockData implements Cloneable {
String languageCode, int uiProfile, int inputMode, String ip,
LinkedPlayer linkedPlayer, boolean fromProxy, int subscribeId,
String verifyCode, TimeSyncer timeSyncer) {
long realMillis = System.currentTimeMillis();
if (timeSyncer.getTimeOffset() != Long.MIN_VALUE) {
realMillis += timeSyncer.getTimeOffset();
}
return new BedrockData(version, username, xuid, deviceOs, languageCode, inputMode,
uiProfile, ip, linkedPlayer, fromProxy, subscribeId, verifyCode,
realMillis, EXPECTED_LENGTH);
timeSyncer.getRealMillis(), EXPECTED_LENGTH);
}
public static BedrockData of(

Datei anzeigen

@ -695,6 +695,14 @@ public class GeyserSession implements CommandSender {
skinUploader.getVerifyCode(),
connector.getTimeSyncer()
).toString());
if (!connector.getTimeSyncer().hasUsefulOffset()) {
connector.getLogger().warning(
"We couldn't make sure that your system clock is accurate. " +
"This can cause issues with logging in."
);
}
} catch (Exception e) {
connector.getLogger().error(LanguageUtils.getLocaleStringLog("geyser.auth.floodgate.encrypt_fail"), e);
disconnect(LanguageUtils.getPlayerLocaleString("geyser.auth.floodgate.encryption_fail", getClientData().getLanguageCode()));