Updated Netty library.
This commit is contained in:
@@ -33,7 +33,7 @@ import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
|
||||
public class ClientInitializer extends ChannelInitializer<SocketChannel>
|
||||
{
|
||||
private static final LengthFieldBasedFrameEncoder LENGTH_ENCODER = new LengthFieldBasedFrameEncoder();
|
||||
private static final PacketEncoder PACKET_ENCODER = new PacketEncoder(ByteOrder.LITTLE_ENDIAN, 0x8000 - 2);
|
||||
private static final PacketEncoder PACKET_ENCODER = new PacketEncoder(0x8000 - 2);
|
||||
|
||||
@Override
|
||||
protected void initChannel(SocketChannel ch)
|
||||
@@ -43,7 +43,7 @@ public class ClientInitializer extends ChannelInitializer<SocketChannel>
|
||||
ch.pipeline().addLast("length-encoder", LENGTH_ENCODER);
|
||||
ch.pipeline().addLast("crypt-codec", new CryptCodec(client.getCrypt()));
|
||||
// ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO));
|
||||
ch.pipeline().addLast("packet-decoder", new PacketDecoder<>(ByteOrder.LITTLE_ENDIAN, IncomingPackets.PACKET_ARRAY, client));
|
||||
ch.pipeline().addLast("packet-decoder", new PacketDecoder<>(IncomingPackets.PACKET_ARRAY, client));
|
||||
ch.pipeline().addLast("packet-encoder", PACKET_ENCODER);
|
||||
ch.pipeline().addLast(client);
|
||||
}
|
||||
|
@@ -155,7 +155,7 @@ public final class L2GameClient extends ChannelInboundHandler<L2GameClient>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void messageReceived(ChannelHandlerContext ctx, IIncomingPacket<L2GameClient> packet)
|
||||
protected void channelRead0(ChannelHandlerContext ctx, IIncomingPacket<L2GameClient> packet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@@ -27,7 +27,7 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
public class LoginServerHandler extends ChannelInboundHandler<LoginServerHandler>
|
||||
{
|
||||
@Override
|
||||
protected void messageReceived(ChannelHandlerContext ctx, IIncomingPacket<LoginServerHandler> msg) throws Exception
|
||||
protected void channelRead0(ChannelHandlerContext ctx, IIncomingPacket<LoginServerHandler> msg) throws Exception
|
||||
{
|
||||
msg.run(this);
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
|
||||
public class LoginServerInitializer extends ChannelInitializer<SocketChannel>
|
||||
{
|
||||
private static final LengthFieldBasedFrameEncoder LENGTH_ENCODER = new LengthFieldBasedFrameEncoder();
|
||||
private static final PacketEncoder PACKET_ENCODER = new PacketEncoder(ByteOrder.LITTLE_ENDIAN, 0x8000 - 2);
|
||||
private static final PacketEncoder PACKET_ENCODER = new PacketEncoder(0x8000 - 2);
|
||||
|
||||
@Override
|
||||
protected void initChannel(SocketChannel ch)
|
||||
@@ -41,7 +41,7 @@ public class LoginServerInitializer extends ChannelInitializer<SocketChannel>
|
||||
ch.pipeline().addLast("length-decoder", new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 0x8000 - 2, 0, 2, -2, 2, false));
|
||||
ch.pipeline().addLast("length-encoder", LENGTH_ENCODER);
|
||||
// ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO));
|
||||
ch.pipeline().addLast("packet-decoder", new PacketDecoder<>(ByteOrder.LITTLE_ENDIAN, IncomingPackets.PACKET_ARRAY, loginServerHandler));
|
||||
ch.pipeline().addLast("packet-decoder", new PacketDecoder<>(IncomingPackets.PACKET_ARRAY, loginServerHandler));
|
||||
ch.pipeline().addLast("packet-encoder", PACKET_ENCODER);
|
||||
ch.pipeline().addLast(loginServerHandler);
|
||||
}
|
||||
|
@@ -27,15 +27,15 @@ import com.l2jmobius.Config;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerAdapter;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.util.AttributeKey;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
@Sharable
|
||||
public class TelnetServerHandler extends ChannelHandlerAdapter
|
||||
public class TelnetServerHandler extends ChannelInboundHandlerAdapter
|
||||
{
|
||||
private static final Pattern COMMAND_ARGS_PATTERN = Pattern.compile("\"([^\"]*)\"|([^\\s]+)");
|
||||
private static final AttributeKey<Boolean> AUTHORIZED = AttributeKey.valueOf(TelnetServerHandler.class, "AUTHORIZED");
|
||||
@@ -58,7 +58,7 @@ public class TelnetServerHandler extends ChannelHandlerAdapter
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx)
|
||||
public void handlerAdded(ChannelHandlerContext ctx)
|
||||
{
|
||||
String ip = ctx.channel().remoteAddress().toString();
|
||||
ip = ip.substring(1, ip.lastIndexOf(':')); // Trim out /127.0.0.1:14013
|
||||
@@ -79,12 +79,12 @@ public class TelnetServerHandler extends ChannelHandlerAdapter
|
||||
{
|
||||
// Ask password
|
||||
ctx.write("Password:");
|
||||
ctx.attr(AUTHORIZED).set(Boolean.FALSE);
|
||||
ctx.channel().attr(AUTHORIZED).set(Boolean.FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx.write("Type 'help' to see all available commands." + Config.EOL);
|
||||
ctx.attr(AUTHORIZED).set(Boolean.TRUE);
|
||||
ctx.channel().attr(AUTHORIZED).set(Boolean.TRUE);
|
||||
}
|
||||
ctx.flush();
|
||||
}
|
||||
@@ -100,11 +100,11 @@ public class TelnetServerHandler extends ChannelHandlerAdapter
|
||||
String response = null;
|
||||
boolean close = false;
|
||||
|
||||
if (Boolean.FALSE.equals(ctx.attr(AUTHORIZED).get()))
|
||||
if (Boolean.FALSE.equals(ctx.channel().attr(AUTHORIZED).get()))
|
||||
{
|
||||
if (Config.TELNET_PASSWORD.equals(request))
|
||||
{
|
||||
ctx.attr(AUTHORIZED).set(Boolean.TRUE);
|
||||
ctx.channel().attr(AUTHORIZED).set(Boolean.TRUE);
|
||||
request = "";
|
||||
}
|
||||
else
|
||||
@@ -114,7 +114,7 @@ public class TelnetServerHandler extends ChannelHandlerAdapter
|
||||
}
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(ctx.attr(AUTHORIZED).get()))
|
||||
if (Boolean.TRUE.equals(ctx.channel().attr(AUTHORIZED).get()))
|
||||
{
|
||||
if (request.isEmpty())
|
||||
{
|
||||
|
Reference in New Issue
Block a user