ctx.write(new Socks5InitResponse(Socks5AuthScheme.NO_AUTH));
return true;
}
if (msg instanceof Socks5InitRequest) {
ctx.pipeline().addBefore("encoder", "decoder", new Socks5AuthRequestDecoder());
ctx.write(new Socks5InitResponse(Socks5AuthScheme.AUTH_PASSWORD));
return false;
}
Socks5AuthRequest req = (Socks5AuthRequest) msg;
if (req.username().equals(username) && req.password().equals(password)) {
ctx.pipeline().addBefore("encoder", "decoder", new Socks5CmdRequestDecoder());
ctx.write(new Socks5AuthResponse(Socks5AuthStatus.SUCCESS));
return true;
}
ctx.pipeline().addBefore("encoder", "decoder", new Socks5AuthRequestDecoder());
ctx.write(new Socks5AuthResponse(Socks5AuthStatus.FAILURE));
return false;
}