@Override protected boolean handleResponse(ChannelHandlerContext ctx, Object response) throws Exception { final Socks4CommandResponse res = (Socks4CommandResponse) response; final Socks4CommandStatus status = res.status(); if (status == Socks4CommandStatus.SUCCESS) { return true; } throw new ProxyConnectException(exceptionMessage("status: " + status)); } }
@Override protected void encode(ChannelHandlerContext ctx, Socks4CommandResponse msg, ByteBuf out) throws Exception { out.writeByte(0); out.writeByte(msg.status().byteValue()); out.writeShort(msg.dstPort()); out.writeBytes(msg.dstAddr() == null? IPv4_HOSTNAME_ZEROED : NetUtil.createByteArrayFromIpAddressString(msg.dstAddr())); } }
@Override protected boolean handleResponse(ChannelHandlerContext ctx, Object response) throws Exception { final Socks4CommandResponse res = (Socks4CommandResponse) response; final Socks4CommandStatus status = res.status(); if (status == Socks4CommandStatus.SUCCESS) { return true; } throw new ProxyConnectException(exceptionMessage("status: " + status)); } }
@Override void read(ConnectionFlow flow, Object msg) { removeHandlerIfPresent(SOCKS_ENCODER_NAME); removeHandlerIfPresent(SOCKS_DECODER_NAME); if (msg instanceof Socks4CommandResponse) { if (((Socks4CommandResponse) msg).status() == Socks4CommandStatus.SUCCESS) { flow.advance(); return; } } flow.fail(); }
@Override protected boolean handleResponse(ChannelHandlerContext ctx, Object response) throws Exception { final Socks4CommandResponse res = (Socks4CommandResponse) response; final Socks4CommandStatus status = res.status(); if (status == Socks4CommandStatus.SUCCESS) { return true; } throw new ProxyConnectException(exceptionMessage("status: " + status)); } }
@Override protected void encode(ChannelHandlerContext ctx, Socks4CommandResponse msg, ByteBuf out) throws Exception { out.writeByte(0); out.writeByte(msg.status().byteValue()); out.writeShort(msg.dstPort()); out.writeBytes(msg.dstAddr() == null? IPv4_HOSTNAME_ZEROED : NetUtil.createByteArrayFromIpAddressString(msg.dstAddr())); } }
@Override protected void encode(ChannelHandlerContext ctx, Socks4CommandResponse msg, ByteBuf out) throws Exception { out.writeByte(0); out.writeByte(msg.status().byteValue()); out.writeShort(msg.dstPort()); out.writeBytes(msg.dstAddr() == null? IPv4_HOSTNAME_ZEROED : NetUtil.createByteArrayFromIpAddressString(msg.dstAddr())); } }