Advancing further in the login process.

This commit is contained in:
md_5 2013-03-09 10:10:36 +11:00
parent 8a96555cc7
commit bcaafc206f
10 changed files with 14 additions and 16 deletions

View File

@ -12,6 +12,6 @@ public class BulkChunk extends Instruction
short count = in.readShort(); short count = in.readShort();
int size = in.readInt(); int size = in.readInt();
in.readBoolean(); in.readBoolean();
skip( in, size + count * 12 ); in.skipBytes( size + count * 12 );
} }
} }

View File

@ -28,9 +28,4 @@ abstract class Instruction
static final Instruction BYTE_INT = new ByteHeader( INT ); static final Instruction BYTE_INT = new ByteHeader( INT );
abstract void read(ByteBuf in) throws IOException; abstract void read(ByteBuf in) throws IOException;
final void skip(ByteBuf in, int len) throws IOException
{
in.readerIndex( in.readerIndex() + len );
}
} }

View File

@ -12,7 +12,7 @@ class Item extends Instruction
short type = in.readShort(); short type = in.readShort();
if ( type >= 0 ) if ( type >= 0 )
{ {
skip( in, 3 ); in.skipBytes( 3 );
SHORT_BYTE.read( in ); SHORT_BYTE.read( in );
} }
} }

View File

@ -20,6 +20,6 @@ class Jump extends Instruction
@Override @Override
void read(ByteBuf in) throws IOException void read(ByteBuf in) throws IOException
{ {
skip( in, len ); in.skipBytes( len );
} }
} }

View File

@ -34,7 +34,7 @@ class MetaData extends Instruction
ITEM.read( in ); ITEM.read( in );
break; break;
case 6: case 6:
skip( in, 12 ); // int, int, int in.skipBytes( 12 ); // int, int, int
break; break;
default: default:
throw new IllegalArgumentException( "Unknown metadata type " + type ); throw new IllegalArgumentException( "Unknown metadata type " + type );

View File

@ -12,7 +12,7 @@ class OptionalMotion extends Instruction
int data = in.readInt(); int data = in.readInt();
if ( data > 0 ) if ( data > 0 )
{ {
skip( in, 6 ); in.skipBytes( 6 );
} }
} }
} }

View File

@ -10,6 +10,6 @@ class UnsignedShortByte extends Instruction
void read(ByteBuf in) throws IOException void read(ByteBuf in) throws IOException
{ {
int size = in.readUnsignedShort(); int size = in.readUnsignedShort();
skip( in, size ); in.skipBytes( size );
} }
} }

View File

@ -179,8 +179,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
ch.write( new PacketFCEncryptionResponse() ); ch.write( new PacketFCEncryptionResponse() );
Cipher decrypt = EncryptionUtil.getCipher( Cipher.DECRYPT_MODE, shared );
Cipher encrypt = EncryptionUtil.getCipher( Cipher.ENCRYPT_MODE, shared ); Cipher encrypt = EncryptionUtil.getCipher( Cipher.ENCRYPT_MODE, shared );
Cipher decrypt = EncryptionUtil.getCipher( Cipher.DECRYPT_MODE, shared );
ch.pipeline().addBefore( "decoder", "cipher", new CipherCodec( encrypt, decrypt ) ); ch.pipeline().addBefore( "decoder", "cipher", new CipherCodec( encrypt, decrypt ) );
thisState = InitialHandler.State.LOGIN; thisState = InitialHandler.State.LOGIN;

View File

@ -60,7 +60,7 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<ByteBuf>
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
{ {
super.exceptionCaught( ctx, cause ); cause.printStackTrace();
if ( ctx.channel().isActive() ) if ( ctx.channel().isActive() )
{ {
ctx.close(); ctx.close();

View File

@ -3,9 +3,11 @@ package net.md_5.bungee.netty;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder; import io.netty.handler.codec.ReplayingDecoder;
import java.io.IOException;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.md_5.bungee.Util;
import net.md_5.bungee.protocol.netty.PacketReader; import net.md_5.bungee.protocol.netty.PacketReader;
/** /**
@ -28,9 +30,10 @@ public class PacketDecoder extends ReplayingDecoder<ByteBuf>
protected ByteBuf decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception protected ByteBuf decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception
{ {
int startIndex = in.readerIndex(); int startIndex = in.readerIndex();
PacketReader.readPacket( in, protocol ); PacketReader.readPacket( in, protocol );
ByteBuf readPacket = in.copy( startIndex, in.readerIndex() - startIndex );
System.out.println( readPacket ); System.out.println( Util.hex( in.getUnsignedByte( 0 ) ) );
return readPacket; return in.copy( startIndex, in.readerIndex() - startIndex );
} }
} }