@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { try { switch (state()) { case INIT: { final int startOffset = in.readerIndex(); in.toString(startOffset + 3 + usernameLength, passwordLength, CharsetUtil.US_ASCII))); checkpoint(State.SUCCESS); int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes)); in.skipBytes(actualReadableBytes()); break; fail(out, e);
private void handleInitialRequest(ChannelHandlerContext ctx, Socks5InitialRequest initialRequest) { String username = ConfigurationProperties.proxyAuthenticationUsername(); String password = ConfigurationProperties.proxyAuthenticationPassword(); Socks5AuthMethod requiredAuthMethod; ChannelHandler nextRequestDecoder; if (!username.isEmpty() && !password.isEmpty()) { requiredAuthMethod = Socks5AuthMethod.PASSWORD; nextRequestDecoder = new Socks5PasswordAuthRequestDecoder(); } else { requiredAuthMethod = Socks5AuthMethod.NO_AUTH; nextRequestDecoder = new Socks5CommandRequestDecoder(); } answerInitialRequest(ctx, initialRequest, requiredAuthMethod, nextRequestDecoder); }
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); } checkpoint(State.FAILURE); Socks5Message m = new DefaultSocks5PasswordAuthRequest("", ""); m.setDecoderResult(DecoderResult.failure(cause)); out.add(m); } }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { try { switch (state()) { case INIT: { final int startOffset = in.readerIndex(); in.toString(startOffset + 3 + usernameLength, passwordLength, CharsetUtil.US_ASCII))); checkpoint(State.SUCCESS); int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes)); in.skipBytes(actualReadableBytes()); break; fail(out, e);
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 handleInitialRequest(ChannelHandlerContext ctx, Socks5InitialRequest initialRequest) { String username = ConfigurationProperties.proxyAuthenticationUsername(); String password = ConfigurationProperties.proxyAuthenticationPassword(); Socks5AuthMethod requiredAuthMethod; ChannelHandler nextRequestDecoder; if (!username.isEmpty() && !password.isEmpty()) { requiredAuthMethod = Socks5AuthMethod.PASSWORD; nextRequestDecoder = new Socks5PasswordAuthRequestDecoder(); } else { requiredAuthMethod = Socks5AuthMethod.NO_AUTH; nextRequestDecoder = new Socks5CommandRequestDecoder(); } answerInitialRequest(ctx, initialRequest, requiredAuthMethod, nextRequestDecoder); }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { try { switch (state()) { case INIT: { final int startOffset = in.readerIndex(); in.toString(startOffset + 3 + usernameLength, passwordLength, CharsetUtil.US_ASCII))); checkpoint(State.SUCCESS); int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes)); in.skipBytes(actualReadableBytes()); break; fail(out, e);