@Override public byte readByte() { return buffer.readByte(); }
@Override protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, State state) throws Exception { switch (state) { case CHECK_PROTOCOL_VERSION: { version = SocksMessage.SubnegotiationVersion.fromByte(buffer.readByte()); if (version != SocksMessage.SubnegotiationVersion.AUTH_PASSWORD) { break; } checkpoint(State.READ_USERNAME); } case READ_USERNAME: { fieldLength = buffer.readByte(); username = buffer.readBytes(fieldLength).toString(CharsetUtil.US_ASCII); checkpoint(State.READ_PASSWORD); } case READ_PASSWORD: { fieldLength = buffer.readByte(); password = buffer.readBytes(fieldLength).toString(CharsetUtil.US_ASCII); msg = new SocksAuthRequest(username, password); } } ctx.getPipeline().remove(this); return msg; }
private WebSocketFrame decodeBinaryFrame(byte type, ChannelBuffer buffer) throws TooLongFrameException { long frameSize = 0; int lengthFieldSize = 0; byte b; do { b = buffer.readByte(); frameSize <<= 7; frameSize |= b & 0x7f; if (frameSize > maxFrameSize) { throw new TooLongFrameException(); } lengthFieldSize++; if (lengthFieldSize > 8) { // Perhaps a malicious peer? throw new TooLongFrameException(); } } while ((b & 0x80) == 0x80); if (type == (byte) 0xFF && frameSize == 0) { receivedClosingHandshake = true; return new CloseWebSocketFrame(); } return new BinaryWebSocketFrame(buffer.readBytes((int) frameSize)); }
@Override public byte readByte() { return buffer.readByte(); }
boolean isRequest = isV2Request(buffer.readByte()); buffer.skipBytes(2); long requestId = buffer.readLong();
@Override public int readByte() { return buffer.readByte(); }
@Override public int readByte() { return buffer.readByte(); }
public int read() throws IOException { if (buffer.readable()) { return buffer.readByte() & 0xff; } return -1; }
@Override public int read() throws IOException { if (!buffer.readable()) { return -1; } return buffer.readByte() & 0xff; }
public byte readByte() throws IOException { if (!buffer.readable()) { throw new EOFException(); } return buffer.readByte(); }
private Event extractEvent(ChannelBuffer in, SocketAddress remoteAddress) { Map<String, String> headers = new HashMap<String,String>(); headers.put(remoteHostHeader, remoteAddress.toString()); byte b = 0; ByteArrayOutputStream baos = new ByteArrayOutputStream(); Event e = null; boolean doneReading = false; try { while (!doneReading && in.readable()) { b = in.readByte(); // Entries are separated by '\n' if (b == '\n') { doneReading = true; } else { baos.write(b); } } e = EventBuilder.withBody(baos.toByteArray(), headers); } finally { // no-op } return e; }
public byte readByte() { checkReadableBytes(1); return buf().readByte(); }
@Override protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { if(null == msg) { LOG.error("Null message received in MessageBufferEventDecoder"); return msg; } ChannelBuffer buffer = (ChannelBuffer)msg; byte opcode = buffer.readByte(); if (opcode == Events.NETWORK_MESSAGE) { opcode = Events.SESSION_MESSAGE; } return Events.event(new NettyMessageBuffer(buffer), opcode); } }
@Override protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { if (null == msg) { return msg; } ChannelBuffer buffer = (ChannelBuffer) msg; byte opcode = buffer.readByte(); if (opcode == Events.NETWORK_MESSAGE) { opcode = Events.SESSION_MESSAGE; } return Events.event(new NettyMessageBuffer(buffer), opcode); }
@Override protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, State state) throws Exception { switch (state) { case CHECK_PROTOCOL_VERSION: { version = SocksMessage.ProtocolVersion.fromByte(buffer.readByte()); if (version != SocksMessage.ProtocolVersion.SOCKS5) { break; } checkpoint(State.READ_AUTH_SCHEMES); } case READ_AUTH_SCHEMES: { authSchemes.clear(); authSchemeNum = buffer.readByte(); for (int i = 0; i < authSchemeNum; i++) { authSchemes.add(SocksMessage.AuthScheme.fromByte(buffer.readByte())); } msg = new SocksInitRequest(authSchemes); break; } } ctx.getPipeline().remove(this); return msg; }
@Override protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, State state) throws Exception { switch (state) { case CHECK_PROTOCOL_VERSION: { version = SocksMessage.SubnegotiationVersion.fromByte(buffer.readByte()); if (version != SocksMessage.SubnegotiationVersion.AUTH_PASSWORD) { break; } checkpoint(State.READ_AUTH_RESPONSE); } case READ_AUTH_RESPONSE: { authStatus = SocksMessage.AuthStatus.fromByte(buffer.readByte()); msg = new SocksAuthResponse(authStatus); } } ctx.getPipeline().remove(this); return msg; }
@Override protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, State state) throws Exception { switch (state) { case CHECK_PROTOCOL_VERSION: { version = SocksMessage.ProtocolVersion.fromByte(buffer.readByte()); if (version != SocksMessage.ProtocolVersion.SOCKS5) { break; } checkpoint(State.READ_PREFFERED_AUTH_TYPE); } case READ_PREFFERED_AUTH_TYPE: { authScheme = SocksMessage.AuthScheme.fromByte(buffer.readByte()); msg = new SocksInitResponse(authScheme); break; } } ctx.getPipeline().remove(this); return msg; }
@Override protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws Exception { // Discard all data received if closing handshake was received before. if (receivedClosingHandshake) { buffer.skipBytes(actualReadableBytes()); return null; } // Decode a frame otherwise. byte type = buffer.readByte(); if ((type & 0x80) == 0x80) { // If the MSB on type is set, decode the frame length return decodeBinaryFrame(type, buffer); } else { // Decode a 0xff terminated UTF-8 string return decodeTextFrame(buffer); } }
/** * Skip one empty line * @return True if one empty line was skipped */ private boolean skipOneLine() { if (!undecodedChunk.readable()) { return false; } byte nextByte = undecodedChunk.readByte(); if (nextByte == HttpConstants.CR) { if (!undecodedChunk.readable()) { undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 1); return false; } nextByte = undecodedChunk.readByte(); if (nextByte == HttpConstants.LF) { return true; } undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 2); return false; } if (nextByte == HttpConstants.LF) { return true; } undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 1); return false; }
int rpcVersion = (buffer.readByte() & 0xff) >>> 3; Object result; switch (rpcVersion) {