@Override public void encodeAsByteBuf(ByteBuf byteBuf) { byteBuf.writeByte(SUBNEGOTIATION_VERSION.byteValue()); byteBuf.writeByte(authStatus.byteValue()); } }
@Override public void encodeAsByteBuf(ByteBuf byteBuf) { byteBuf.writeByte(SUBNEGOTIATION_VERSION.byteValue()); byteBuf.writeByte(username.length()); byteBuf.writeCharSequence(username, CharsetUtil.US_ASCII); byteBuf.writeByte(password.length()); byteBuf.writeCharSequence(password, CharsetUtil.US_ASCII); } }
@Override protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> out) throws Exception { switch (state()) { case CHECK_PROTOCOL_VERSION: { if (byteBuf.readByte() != SocksSubnegotiationVersion.AUTH_PASSWORD.byteValue()) { out.add(SocksCommonUtils.UNKNOWN_SOCKS_RESPONSE); break; } checkpoint(State.READ_AUTH_RESPONSE); } case READ_AUTH_RESPONSE: { SocksAuthStatus authStatus = SocksAuthStatus.valueOf(byteBuf.readByte()); out.add(new SocksAuthResponse(authStatus)); break; } default: { throw new Error(); } } channelHandlerContext.pipeline().remove(this); }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception { switch (state()) { case CHECK_PROTOCOL_VERSION: { if (byteBuf.readByte() != SocksSubnegotiationVersion.AUTH_PASSWORD.byteValue()) { out.add(SocksCommonUtils.UNKNOWN_SOCKS_REQUEST); break; } checkpoint(State.READ_USERNAME); } case READ_USERNAME: { int fieldLength = byteBuf.readByte(); username = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); checkpoint(State.READ_PASSWORD); } case READ_PASSWORD: { int fieldLength = byteBuf.readByte(); String password = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); out.add(new SocksAuthRequest(username, password)); break; } default: { throw new Error(); } } ctx.pipeline().remove(this); }
@Override public void encodeAsByteBuf(ByteBuf byteBuf) { byteBuf.writeByte(SUBNEGOTIATION_VERSION.byteValue()); byteBuf.writeByte(authStatus.byteValue()); } }
@Override public void encodeAsByteBuf(ByteBuf byteBuf) { byteBuf.writeByte(SUBNEGOTIATION_VERSION.byteValue()); byteBuf.writeByte(authStatus.byteValue()); } }
@Override public void encodeAsByteBuf(ByteBuf byteBuf) { byteBuf.writeByte(SUBNEGOTIATION_VERSION.byteValue()); byteBuf.writeByte(username.length()); byteBuf.writeCharSequence(username, CharsetUtil.US_ASCII); byteBuf.writeByte(password.length()); byteBuf.writeCharSequence(password, CharsetUtil.US_ASCII); } }
@Override public void encodeAsByteBuf(ByteBuf byteBuf) { byteBuf.writeByte(SUBNEGOTIATION_VERSION.byteValue()); byteBuf.writeByte(username.length()); byteBuf.writeCharSequence(username, CharsetUtil.US_ASCII); byteBuf.writeByte(password.length()); byteBuf.writeCharSequence(password, CharsetUtil.US_ASCII); } }
@Override protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> out) throws Exception { switch (state()) { case CHECK_PROTOCOL_VERSION: { if (byteBuf.readByte() != SocksSubnegotiationVersion.AUTH_PASSWORD.byteValue()) { out.add(SocksCommonUtils.UNKNOWN_SOCKS_RESPONSE); break; } checkpoint(State.READ_AUTH_RESPONSE); } case READ_AUTH_RESPONSE: { SocksAuthStatus authStatus = SocksAuthStatus.valueOf(byteBuf.readByte()); out.add(new SocksAuthResponse(authStatus)); break; } default: { throw new Error(); } } channelHandlerContext.pipeline().remove(this); }
@Override protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> out) throws Exception { switch (state()) { case CHECK_PROTOCOL_VERSION: { if (byteBuf.readByte() != SocksSubnegotiationVersion.AUTH_PASSWORD.byteValue()) { out.add(SocksCommonUtils.UNKNOWN_SOCKS_RESPONSE); break; } checkpoint(State.READ_AUTH_RESPONSE); } case READ_AUTH_RESPONSE: { SocksAuthStatus authStatus = SocksAuthStatus.valueOf(byteBuf.readByte()); out.add(new SocksAuthResponse(authStatus)); break; } default: { throw new Error(); } } channelHandlerContext.pipeline().remove(this); }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception { switch (state()) { case CHECK_PROTOCOL_VERSION: { if (byteBuf.readByte() != SocksSubnegotiationVersion.AUTH_PASSWORD.byteValue()) { out.add(SocksCommonUtils.UNKNOWN_SOCKS_REQUEST); break; } checkpoint(State.READ_USERNAME); } case READ_USERNAME: { int fieldLength = byteBuf.readByte(); username = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); checkpoint(State.READ_PASSWORD); } case READ_PASSWORD: { int fieldLength = byteBuf.readByte(); String password = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); out.add(new SocksAuthRequest(username, password)); break; } default: { throw new Error(); } } ctx.pipeline().remove(this); }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception { switch (state()) { case CHECK_PROTOCOL_VERSION: { if (byteBuf.readByte() != SocksSubnegotiationVersion.AUTH_PASSWORD.byteValue()) { out.add(SocksCommonUtils.UNKNOWN_SOCKS_REQUEST); break; } checkpoint(State.READ_USERNAME); } case READ_USERNAME: { int fieldLength = byteBuf.readByte(); username = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); checkpoint(State.READ_PASSWORD); } case READ_PASSWORD: { int fieldLength = byteBuf.readByte(); String password = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); out.add(new SocksAuthRequest(username, password)); break; } default: { throw new Error(); } } ctx.pipeline().remove(this); }