Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-07-31 17:48:08 +02:00
Simplify disconnection logging
A disconnect message will always be printed, but not more than once. CLOSED_BY_REMOTE_PEER -> Bedrock client disconnected (hopefully slightly less vague) If a message is sent from the server, the log will now indicate their disconnection reason.
Dieser Commit ist enthalten in:
Ursprung
50bed6a2be
Commit
8388a4830e
|
@ -74,11 +74,9 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
||||||
String supportedVersions = MinecraftProtocol.getAllSupportedBedrockVersions();
|
String supportedVersions = MinecraftProtocol.getAllSupportedBedrockVersions();
|
||||||
if (loginPacket.getProtocolVersion() > MinecraftProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
|
if (loginPacket.getProtocolVersion() > MinecraftProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
|
||||||
// Too early to determine session locale
|
// Too early to determine session locale
|
||||||
session.getGeyser().getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.outdated.server", supportedVersions));
|
|
||||||
session.disconnect(GeyserLocale.getLocaleStringLog("geyser.network.outdated.server", supportedVersions));
|
session.disconnect(GeyserLocale.getLocaleStringLog("geyser.network.outdated.server", supportedVersions));
|
||||||
return true;
|
return true;
|
||||||
} else if (loginPacket.getProtocolVersion() < MinecraftProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
|
} else if (loginPacket.getProtocolVersion() < MinecraftProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
|
||||||
session.getGeyser().getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.outdated.client", supportedVersions));
|
|
||||||
session.disconnect(GeyserLocale.getLocaleStringLog("geyser.network.outdated.client", supportedVersions));
|
session.disconnect(GeyserLocale.getLocaleStringLog("geyser.network.outdated.client", supportedVersions));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,7 @@ import org.geysermc.geyser.util.DimensionUtils;
|
||||||
import org.geysermc.geyser.util.LoginEncryptionUtils;
|
import org.geysermc.geyser.util.LoginEncryptionUtils;
|
||||||
import org.geysermc.geyser.util.MathUtils;
|
import org.geysermc.geyser.util.MathUtils;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
@ -125,13 +126,13 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@Getter
|
@Getter
|
||||||
public class GeyserSession implements GeyserConnection, CommandSender {
|
public class GeyserSession implements GeyserConnection, CommandSender {
|
||||||
|
|
||||||
private final GeyserImpl geyser;
|
private final @Nonnull GeyserImpl geyser;
|
||||||
private final UpstreamSession upstream;
|
private final @Nonnull UpstreamSession upstream;
|
||||||
/**
|
/**
|
||||||
* The loop where all packets and ticking is processed to prevent concurrency issues.
|
* The loop where all packets and ticking is processed to prevent concurrency issues.
|
||||||
* If this is manually called, ensure that any exceptions are properly handled.
|
* If this is manually called, ensure that any exceptions are properly handled.
|
||||||
*/
|
*/
|
||||||
private final EventLoop eventLoop;
|
private final @Nonnull EventLoop eventLoop;
|
||||||
private TcpSession downstream;
|
private TcpSession downstream;
|
||||||
@Setter
|
@Setter
|
||||||
private AuthData authData;
|
private AuthData authData;
|
||||||
|
@ -547,11 +548,14 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
bedrockServerSession.addDisconnectHandler(disconnectReason -> {
|
bedrockServerSession.addDisconnectHandler(disconnectReason -> {
|
||||||
InetAddress address = bedrockServerSession.getRealAddress().getAddress();
|
String message = switch (disconnectReason) {
|
||||||
geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.disconnect", address, disconnectReason));
|
// A generic message that just means the player quit normally.
|
||||||
|
case CLOSED_BY_REMOTE_PEER -> GeyserLocale.getLocaleStringLog("geyser.network.disconnect.closed_by_remote_peer");
|
||||||
|
case TIMED_OUT -> GeyserLocale.getLocaleStringLog("geyser.network.disconnect.timed_out");
|
||||||
|
default -> disconnectReason.name();
|
||||||
|
};
|
||||||
|
|
||||||
disconnect(disconnectReason.name());
|
disconnect(message);
|
||||||
geyser.getSessionManager().removeSession(this);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.remoteAddress = geyser.getConfig().getRemote().getAddress();
|
this.remoteAddress = geyser.getConfig().getRemote().getAddress();
|
||||||
|
@ -1009,11 +1013,16 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
||||||
loggedIn = false;
|
loggedIn = false;
|
||||||
if (downstream != null) {
|
if (downstream != null) {
|
||||||
downstream.disconnect(reason);
|
downstream.disconnect(reason);
|
||||||
|
} else {
|
||||||
|
// Downstream's disconnect will fire an event that prints a log message
|
||||||
|
// Otherwise, we print a message here
|
||||||
|
InetAddress address = upstream.getAddress().getAddress();
|
||||||
|
geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.disconnect", address, reason));
|
||||||
}
|
}
|
||||||
if (upstream != null && !upstream.isClosed()) {
|
if (!upstream.isClosed()) {
|
||||||
geyser.getSessionManager().removeSession(this);
|
|
||||||
upstream.disconnect(reason);
|
upstream.disconnect(reason);
|
||||||
}
|
}
|
||||||
|
geyser.getSessionManager().removeSession(this);
|
||||||
if (authData != null) {
|
if (authData != null) {
|
||||||
PendingMicrosoftAuthentication.AuthenticationTask task = geyser.getPendingMicrosoftAuthentication().getTask(authData.xuid());
|
PendingMicrosoftAuthentication.AuthenticationTask task = geyser.getPendingMicrosoftAuthentication().getTask(authData.xuid());
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
|
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren