Refine search
if (length >= threshold) { throw new DecoderException( "Received uncompressed message of size " + length + " greater than threshold " + threshold); out.add(buf); } else { out.add(msg); } else if (resultLength != uncompressedSize) { throw new DecoderException( "Received compressed message claiming to be of size " + uncompressedSize + " but actually " + resultLength); } else { out.add(Unpooled.wrappedBuffer(destData));
private void fail(List<Object> out, Exception cause) { if (!(cause instanceof DecoderException)) { cause = new DecoderException(cause); } checkpoint(State.FAILURE); Socks5Message m = new DefaultSocks5InitialResponse(Socks5AuthMethod.UNACCEPTED); m.setDecoderResult(DecoderResult.failure(cause)); out.add(m); } }
private void fail(List<Object> out, Exception cause) { if (!(cause instanceof DecoderException)) { cause = new DecoderException(cause); } checkpoint(State.FAILURE); Socks5Message m = new DefaultSocks5CommandResponse( Socks5CommandStatus.FAILURE, Socks5AddressType.IPv4, null, 0); m.setDecoderResult(DecoderResult.failure(cause)); out.add(m); } }
private void fail(List<Object> out, Exception cause) { if (!(cause instanceof DecoderException)) { cause = new DecoderException(cause); } checkpoint(State.FAILURE); Socks5Message m = new DefaultSocks5CommandRequest( Socks5CommandType.CONNECT, Socks5AddressType.IPv4, "0.0.0.0", 1); m.setDecoderResult(DecoderResult.failure(cause)); out.add(m); } }
private void fail(List<Object> out, Exception cause) { if (!(cause instanceof DecoderException)) { cause = new DecoderException(cause); } checkpoint(State.FAILURE); Socks5Message m = new DefaultSocks5InitialRequest(Socks5AuthMethod.NO_AUTH); m.setDecoderResult(DecoderResult.failure(cause)); out.add(m); } }
private void fail(List<Object> out, Exception cause) { if (!(cause instanceof DecoderException)) { cause = new DecoderException(cause); } checkpoint(State.FAILURE); Socks5Message m = new DefaultSocks5PasswordAuthRequest("", ""); m.setDecoderResult(DecoderResult.failure(cause)); out.add(m); } }
private void fail(List<Object> out, Exception cause) { if (!(cause instanceof DecoderException)) { cause = new DecoderException(cause); } Socks4CommandResponse m = new DefaultSocks4CommandResponse(Socks4CommandStatus.REJECTED_OR_FAILED); m.setDecoderResult(DecoderResult.failure(cause)); out.add(m); checkpoint(State.FAILURE); } }
private void fail(List<Object> out, Exception cause) { if (!(cause instanceof DecoderException)) { cause = new DecoderException(cause); } checkpoint(State.FAILURE); Socks5Message m = new DefaultSocks5PasswordAuthResponse(Socks5PasswordAuthStatus.FAILURE); m.setDecoderResult(DecoderResult.failure(cause)); out.add(m); } }
private void fail(List<Object> out, Exception cause) { if (!(cause instanceof DecoderException)) { cause = new DecoderException(cause); } Socks4CommandRequest m = new DefaultSocks4CommandRequest( type != null? type : Socks4CommandType.CONNECT, dstAddr != null? dstAddr : "", dstPort != 0? dstPort : 65535, userId != null? userId : ""); m.setDecoderResult(DecoderResult.failure(cause)); out.add(m); checkpoint(State.FAILURE); }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { try { switch (state()) { case INIT: { final byte version = in.readByte(); if (version != 1) { throw new DecoderException("unsupported subnegotiation version: " + version + " (expected: 1)"); } out.add(new DefaultSocks5PasswordAuthResponse(Socks5PasswordAuthStatus.valueOf(in.readByte()))); checkpoint(State.SUCCESS); } case SUCCESS: { int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes)); } break; } case FAILURE: { in.skipBytes(actualReadableBytes()); break; } } } catch (Exception e) { fail(out, e); } }
final byte version = in.getByte(startOffset); if (version != 1) { throw new DecoderException("unsupported subnegotiation version: " + version + " (expected: 1)"); out.add(new DefaultSocks5PasswordAuthRequest( in.toString(startOffset + 2, usernameLength, CharsetUtil.US_ASCII), in.toString(startOffset + 3 + usernameLength, passwordLength, CharsetUtil.US_ASCII))); int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes));
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { try { switch (state()) { case INIT: { final byte version = in.readByte(); if (version != SocksVersion.SOCKS5.byteValue()) { throw new DecoderException( "unsupported version: " + version + " (expected: " + SocksVersion.SOCKS5.byteValue() + ')'); } final Socks5AuthMethod authMethod = Socks5AuthMethod.valueOf(in.readByte()); out.add(new DefaultSocks5InitialResponse(authMethod)); checkpoint(State.SUCCESS); } case SUCCESS: { int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes)); } break; } case FAILURE: { in.skipBytes(actualReadableBytes()); break; } } } catch (Exception e) { fail(out, e); } }
final byte version = in.readByte(); if (version != SocksVersion.SOCKS5.byteValue()) { throw new DecoderException( "unsupported version: " + version + " (expected: " + SocksVersion.SOCKS5.byteValue() + ')'); final int port = in.readUnsignedShort(); out.add(new DefaultSocks5CommandResponse(status, addrType, addr, port)); checkpoint(State.SUCCESS); int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes));
final byte version = in.readByte(); if (version != SocksVersion.SOCKS5.byteValue()) { throw new DecoderException( "unsupported version: " + version + " (expected: " + SocksVersion.SOCKS5.byteValue() + ')'); final int dstPort = in.readUnsignedShort(); out.add(new DefaultSocks5CommandRequest(type, dstAddrType, dstAddr, dstPort)); checkpoint(State.SUCCESS); int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes));
final int version = in.readUnsignedByte(); if (version != 0) { throw new DecoderException("unsupported reply version: " + version + " (expected: 0)"); final String dstAddr = NetUtil.intToIpAddress(in.readInt()); out.add(new DefaultSocks4CommandResponse(status, dstAddr, dstPort)); checkpoint(State.SUCCESS); int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes));
out.add(invalidMessage(cause)); return; throw new DecoderException("too large message: " + bytesRemainingInVariablePart + " bytes"); out.add(invalidMessage(cause)); return; bytesRemainingInVariablePart -= decodedPayload.numberOfBytesConsumed; if (bytesRemainingInVariablePart != 0) { throw new DecoderException( "non-zero remaining payload bytes: " + bytesRemainingInVariablePart + " (" + mqttFixedHeader.messageType() + ')'); mqttFixedHeader = null; variableHeader = null; out.add(message); break; } catch (Exception cause) {
final byte version = in.readByte(); if (version != SocksVersion.SOCKS5.byteValue()) { throw new DecoderException( "unsupported version: " + version + " (expected: " + SocksVersion.SOCKS5.byteValue() + ')'); out.add(new DefaultSocks5InitialRequest(authMethods)); checkpoint(State.SUCCESS); int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes));
final int version = in.readUnsignedByte(); if (version != SocksVersion.SOCKS4a.byteValue()) { throw new DecoderException("unsupported protocol version: " + version); dstAddr = readString("dstAddr", in); out.add(new DefaultSocks4CommandRequest(type, dstAddr, dstPort, userId)); checkpoint(State.SUCCESS); int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes));
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf input, List<Object> list) throws IllegalAccessException, InstantiationException { if (!input.isReadable()) { return; } EnumProtocol protocol = ctx.channel().attr(NetworkManager.c).get(); wrapper.setBuf(input); int packetId = VarNumberSerializer.readVarInt(wrapper); Packet<?> packet = protocol.a(EnumProtocolDirection.SERVERBOUND, packetId); if (packet == null) { throw new DecoderException("Bad packet id " + packetId); } try { packet.a(nativeSerializer); } catch (IOException e) { throw new DecoderException(e); } if (nativeSerializer.isReadable()) { throw new DecoderException("Did not read all data from packet " + packet.getClass().getName() + ", bytes left: " + nativeSerializer.readableBytes()); } list.add(packet); }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf from, List<Object> list) throws Exception { if (!from.isReadable()) { return; } int uncompressedlength = VarNumberSerializer.readVarInt(from); if (uncompressedlength == 0) { list.add(from.retain()); } else { if (uncompressedlength > maxPacketLength) { throw new DecoderException(MessageFormat.format("Badly compressed packet - size of {0} is larger than protocol maximum of {1}", uncompressedlength, maxPacketLength)); } ByteBuf out = ctx.alloc().heapBuffer(uncompressedlength); readBuffer.readFrom(from, (larray, loffset, llength) -> decompressor.decompressTo(out, larray, loffset, llength, uncompressedlength)); list.add(out); } }