3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-24 15:20:35 +01:00

Fix unsigned commands detected as signed (#1082)

* fix: commands flagged as signed without signed arguments

* feat: improve error message for illegal protocol state.
Dieser Commit ist enthalten in:
Joo200 2023-10-12 16:51:19 +02:00 committet von GitHub
Ursprung 1cc3f120ee
Commit 0d9a097a59
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
4 geänderte Dateien mit 40 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -49,4 +49,12 @@ public class LastSeenMessages {
public boolean isEmpty() {
return acknowledged.isEmpty();
}
@Override
public String toString() {
return "LastSeenMessages{" +
"offset=" + offset +
", acknowledged=" + acknowledged +
'}';
}
}

Datei anzeigen

@ -52,7 +52,7 @@ public class KeyedCommandHandler implements CommandHandler<KeyedPlayerCommand> {
&& playerKey.getKeyRevision().compareTo(IdentifiedKey.Revision.LINKED_V2) >= 0) {
logger.fatal("A plugin tried to deny a command with signable component(s). "
+ "This is not supported. "
+ "Disconnecting player " + player.getUsername());
+ "Disconnecting player " + player.getUsername() + ". Command packet: " + packet);
player.disconnect(Component.text(
"A proxy plugin caused an illegal protocol state. "
+ "Contact your network administrator."));
@ -75,7 +75,7 @@ public class KeyedCommandHandler implements CommandHandler<KeyedPlayerCommand> {
&& playerKey.getKeyRevision().compareTo(IdentifiedKey.Revision.LINKED_V2) >= 0) {
logger.fatal("A plugin tried to change a command with signed component(s). "
+ "This is not supported. "
+ "Disconnecting player " + player.getUsername());
+ "Disconnecting player " + player.getUsername() + ". Command packet: " + packet);
player.disconnect(Component.text(
"A proxy plugin caused an illegal protocol state. "
+ "Contact your network administrator."));
@ -95,7 +95,7 @@ public class KeyedCommandHandler implements CommandHandler<KeyedPlayerCommand> {
&& playerKey.getKeyRevision().compareTo(IdentifiedKey.Revision.LINKED_V2) >= 0) {
logger.fatal("A plugin tried to change a command with signed component(s). "
+ "This is not supported. "
+ "Disconnecting player " + player.getUsername());
+ "Disconnecting player " + player.getUsername() + ". Command packet: " + packet);
player.disconnect(Component.text(
"A proxy plugin caused an illegal protocol state. "
+ "Contact your network administrator."));

Datei anzeigen

@ -47,7 +47,7 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
if (packet.isSigned()) {
logger.fatal("A plugin tried to deny a command with signable component(s). "
+ "This is not supported. "
+ "Disconnecting player " + player.getUsername());
+ "Disconnecting player " + player.getUsername() + ". Command packet: " + packet);
player.disconnect(Component.text(
"A proxy plugin caused an illegal protocol state. "
+ "Contact your network administrator."));
@ -63,7 +63,7 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
if (packet.isSigned()) {
logger.fatal("A plugin tried to change a command with signed component(s). "
+ "This is not supported. "
+ "Disconnecting player " + player.getUsername());
+ "Disconnecting player " + player.getUsername() + ". Command packet: " + packet);
player.disconnect(Component.text(
"A proxy plugin caused an illegal protocol state. "
+ "Contact your network administrator."));
@ -87,7 +87,7 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
if (packet.isSigned()) {
logger.fatal("A plugin tried to change a command with signed component(s). "
+ "This is not supported. "
+ "Disconnecting player " + player.getUsername());
+ "Disconnecting player " + player.getUsername() + ". Command packet: " + packet);
player.disconnect(Component.text(
"A proxy plugin caused an illegal protocol state. "
+ "Contact your network administrator."));

Datei anzeigen

@ -65,7 +65,8 @@ public class SessionPlayerCommand implements MinecraftPacket {
}
public boolean isSigned() {
return salt != 0 || !lastSeenMessages.isEmpty() || !argumentSignatures.isEmpty();
if (salt == 0) return false;
return !lastSeenMessages.isEmpty() || !argumentSignatures.isEmpty();
}
@Override
@ -73,6 +74,17 @@ public class SessionPlayerCommand implements MinecraftPacket {
return handler.handle(this);
}
@Override
public String toString() {
return "SessionPlayerCommand{" +
"command='" + command + '\'' +
", timeStamp=" + timeStamp +
", salt=" + salt +
", argumentSignatures=" + argumentSignatures +
", lastSeenMessages=" + lastSeenMessages +
'}';
}
public static class ArgumentSignatures {
private final List<ArgumentSignature> entries;
@ -104,6 +116,12 @@ public class SessionPlayerCommand implements MinecraftPacket {
entry.encode(buf);
}
}
@Override
public String toString() {
return "ArgumentSignatures{" +
"entries=" + entries +
'}';
}
}
public static class ArgumentSignature {
@ -120,5 +138,12 @@ public class SessionPlayerCommand implements MinecraftPacket {
ProtocolUtils.writeString(buf, name);
buf.writeBytes(signature);
}
@Override
public String toString() {
return "ArgumentSignature{" +
"name='" + name + '\'' +
'}';
}
}
}