Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-12-25 15:50:19 +01:00
Fix sending keep alive response to wrong backend server (#1253)
Dieser Commit ist enthalten in:
Ursprung
409ab7b118
Commit
74c932e579
@ -42,6 +42,8 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the client config stage.
|
* Handles the client config stage.
|
||||||
@ -72,17 +74,11 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(KeepAlivePacket packet) {
|
public boolean handle(final KeepAlivePacket packet) {
|
||||||
final VelocityServerConnection serverConnection = player.getConnectedServer();
|
final VelocityServerConnection serverConnection = player.getConnectedServer();
|
||||||
if (serverConnection != null) {
|
if (!this.sendKeepAliveToBackend(serverConnection, packet)) {
|
||||||
final Long sentTime = serverConnection.getPendingPings().remove(packet.getRandomId());
|
final VelocityServerConnection connectionInFlight = player.getConnectionInFlight();
|
||||||
if (sentTime != null) {
|
this.sendKeepAliveToBackend(connectionInFlight, packet);
|
||||||
final MinecraftConnection smc = serverConnection.getConnection();
|
|
||||||
if (smc != null) {
|
|
||||||
player.setPing(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - sentTime));
|
|
||||||
smc.write(packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -177,6 +173,24 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
Component.translatable("velocity.error.player-connection-error", NamedTextColor.RED));
|
Component.translatable("velocity.error.player-connection-error", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean sendKeepAliveToBackend(
|
||||||
|
final @Nullable VelocityServerConnection serverConnection,
|
||||||
|
final @NotNull KeepAlivePacket packet
|
||||||
|
) {
|
||||||
|
if (serverConnection != null) {
|
||||||
|
final Long sentTime = serverConnection.getPendingPings().remove(packet.getRandomId());
|
||||||
|
if (sentTime != null) {
|
||||||
|
final MinecraftConnection smc = serverConnection.getConnection();
|
||||||
|
if (smc != null) {
|
||||||
|
player.setPing(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - sentTime));
|
||||||
|
smc.write(packet);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the backend finishing the config stage.
|
* Handles the backend finishing the config stage.
|
||||||
*
|
*
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren