List of usage examples for io.netty.handler.codec.socksx.v5 Socks5PasswordAuthStatus FAILURE
Socks5PasswordAuthStatus FAILURE
To view the source code for io.netty.handler.codec.socksx.v5 Socks5PasswordAuthStatus FAILURE.
Click Source Link
From source file:com.github.sinsinpub.pero.manual.proxyhandler.Socks5ProxyServer.java
License:Apache License
boolean authenticate(ChannelHandlerContext ctx, Object msg) { if (username == null) { ctx.pipeline().replace(DECODER, DECODER, new Socks5CommandRequestDecoder()); ctx.write(new DefaultSocks5InitialResponse(Socks5AuthMethod.NO_AUTH)); return true; }//from www .ja v a2s . co m if (msg instanceof Socks5InitialRequest) { ctx.pipeline().replace(DECODER, DECODER, new Socks5PasswordAuthRequestDecoder()); ctx.write(new DefaultSocks5InitialResponse(Socks5AuthMethod.PASSWORD)); return false; } Socks5PasswordAuthRequest req = (Socks5PasswordAuthRequest) msg; if (req.username().equals(username) && req.password().equals(password)) { ctx.pipeline().replace(DECODER, DECODER, new Socks5CommandRequestDecoder()); ctx.write(new DefaultSocks5PasswordAuthResponse(Socks5PasswordAuthStatus.SUCCESS)); return true; } ctx.pipeline().replace(DECODER, DECODER, new Socks5PasswordAuthRequestDecoder()); ctx.write(new DefaultSocks5PasswordAuthResponse(Socks5PasswordAuthStatus.FAILURE)); return false; }
From source file:com.slyak.services.proxy.handler.Socks5PasswordAuthRequestHandler.java
License:Apache License
@Override protected void channelRead0(ChannelHandlerContext ctx, DefaultSocks5PasswordAuthRequest msg) throws Exception { if (authProvider.authenticate(msg.username(), msg.password())) { Socks5PasswordAuthResponse passwordAuthResponse = new DefaultSocks5PasswordAuthResponse( Socks5PasswordAuthStatus.SUCCESS); ctx.writeAndFlush(passwordAuthResponse); } else {/* ww w. j av a 2 s .c o m*/ Socks5PasswordAuthResponse passwordAuthResponse = new DefaultSocks5PasswordAuthResponse( Socks5PasswordAuthStatus.FAILURE); //??????channel ctx.writeAndFlush(passwordAuthResponse).addListener(ChannelFutureListener.CLOSE); } }