Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-06 00:00:47 +01:00
Fix GS4 issues.
Dieser Commit ist enthalten in:
Ursprung
3e0df79c98
Commit
b5fcc1b34a
@ -50,8 +50,13 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
|
|||||||
ByteBuf queryMessage = msg.content();
|
ByteBuf queryMessage = msg.content();
|
||||||
InetAddress senderAddress = msg.sender().getAddress();
|
InetAddress senderAddress = msg.sender().getAddress();
|
||||||
|
|
||||||
|
// Allocate buffer for response
|
||||||
|
ByteBuf queryResponse = ctx.alloc().buffer();
|
||||||
|
DatagramPacket responsePacket = new DatagramPacket(queryResponse, msg.sender());
|
||||||
|
|
||||||
|
try {
|
||||||
// Verify query packet magic
|
// Verify query packet magic
|
||||||
if (queryMessage.readUnsignedByte() != QUERY_MAGIC_FIRST && queryMessage.readUnsignedByte() != QUERY_MAGIC_SECOND) {
|
if (queryMessage.readUnsignedByte() != QUERY_MAGIC_FIRST || queryMessage.readUnsignedByte() != QUERY_MAGIC_SECOND) {
|
||||||
throw new IllegalStateException("Invalid query packet magic");
|
throw new IllegalStateException("Invalid query packet magic");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,11 +64,7 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
|
|||||||
short type = queryMessage.readUnsignedByte();
|
short type = queryMessage.readUnsignedByte();
|
||||||
int sessionId = queryMessage.readInt();
|
int sessionId = queryMessage.readInt();
|
||||||
|
|
||||||
// Allocate buffer for response
|
switch (type) {
|
||||||
ByteBuf queryResponse = ctx.alloc().buffer();
|
|
||||||
DatagramPacket responsePacket = new DatagramPacket(queryResponse, msg.sender());
|
|
||||||
|
|
||||||
switch(type) {
|
|
||||||
case QUERY_TYPE_HANDSHAKE: {
|
case QUERY_TYPE_HANDSHAKE: {
|
||||||
// Generate new challenge token and put it into the sessions cache
|
// Generate new challenge token and put it into the sessions cache
|
||||||
int challengeToken = ThreadLocalRandom.current().nextInt();
|
int challengeToken = ThreadLocalRandom.current().nextInt();
|
||||||
@ -123,11 +124,10 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
|
|||||||
|
|
||||||
// Send the response
|
// Send the response
|
||||||
ctx.writeAndFlush(responsePacket);
|
ctx.writeAndFlush(responsePacket);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("Error while trying to handle a query packet from {}", msg.sender(), e);
|
||||||
|
responsePacket.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
|
||||||
logger.warn("Error while trying to handle a query packet from {}", ctx.channel().remoteAddress(), cause);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeString(ByteBuf buf, String string) {
|
private static void writeString(ByteBuf buf, String string) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren