private static void encodePasswordAuthRequest(Socks5PasswordAuthRequest msg, ByteBuf out) { out.writeByte(0x01); final String username = msg.username(); out.writeByte(username.length()); ByteBufUtil.writeAscii(out, username); final String password = msg.password(); out.writeByte(password.length()); ByteBufUtil.writeAscii(out, password); }
private void handlePasswordAuthRequest(ChannelHandlerContext ctx, Socks5PasswordAuthRequest passwordAuthRequest) { String username = ConfigurationProperties.proxyAuthenticationUsername(); String password = ConfigurationProperties.proxyAuthenticationPassword(); // we need the null-check again here, in case the properties got unset between init and auth request if (!username.isEmpty() && !password.isEmpty() && username.equals(passwordAuthRequest.username()) && password.equals(passwordAuthRequest.password())) { ctx.pipeline().replace(Socks5PasswordAuthRequestDecoder.class, null, new Socks5CommandRequestDecoder()); ctx.write(new DefaultSocks5PasswordAuthResponse(Socks5PasswordAuthStatus.SUCCESS)); } else { ctx.writeAndFlush(new DefaultSocks5PasswordAuthResponse(Socks5PasswordAuthStatus.FAILURE)).addListener(ChannelFutureListener.CLOSE); } }
private static void encodePasswordAuthRequest(Socks5PasswordAuthRequest msg, ByteBuf out) { out.writeByte(0x01); final String username = msg.username(); out.writeByte(username.length()); ByteBufUtil.writeAscii(out, username); final String password = msg.password(); out.writeByte(password.length()); ByteBufUtil.writeAscii(out, password); }
private static void encodePasswordAuthRequest(Socks5PasswordAuthRequest msg, ByteBuf out) { out.writeByte(0x01); final String username = msg.username(); out.writeByte(username.length()); ByteBufUtil.writeAscii(out, username); final String password = msg.password(); out.writeByte(password.length()); ByteBufUtil.writeAscii(out, password); }
private void handlePasswordAuthRequest(ChannelHandlerContext ctx, Socks5PasswordAuthRequest passwordAuthRequest) { String username = ConfigurationProperties.proxyAuthenticationUsername(); String password = ConfigurationProperties.proxyAuthenticationPassword(); // we need the null-check again here, in case the properties got unset between init and auth request if (!username.isEmpty() && !password.isEmpty() && username.equals(passwordAuthRequest.username()) && password.equals(passwordAuthRequest.password())) { ctx.pipeline().replace(Socks5PasswordAuthRequestDecoder.class, null, new Socks5CommandRequestDecoder()); ctx.write(new DefaultSocks5PasswordAuthResponse(Socks5PasswordAuthStatus.SUCCESS)); } else { ctx.writeAndFlush(new DefaultSocks5PasswordAuthResponse(Socks5PasswordAuthStatus.FAILURE)).addListener(ChannelFutureListener.CLOSE); } }