Example usage for io.netty.handler.codec.socksx.v5 DefaultSocks5InitialRequest decoderResult

List of usage examples for io.netty.handler.codec.socksx.v5 DefaultSocks5InitialRequest decoderResult

Introduction

In this page you can find the example usage for io.netty.handler.codec.socksx.v5 DefaultSocks5InitialRequest decoderResult.

Prototype

@Override
    public DecoderResult decoderResult() 

Source Link

Usage

From source file:com.slyak.services.proxy.handler.Socks5InitialRequestHandler.java

License:Apache License

@Override
protected void channelRead0(ChannelHandlerContext ctx, DefaultSocks5InitialRequest msg) throws Exception {
    if (msg.decoderResult().isFailure()) {
        ctx.fireChannelRead(msg);/*from   w  w  w . j a  v  a  2 s  .c om*/
    } else {
        if (SocksVersion.SOCKS5.equals(msg.version())) {
            if (isNeedAuth()) {
                Socks5InitialResponse initialResponse = new DefaultSocks5InitialResponse(
                        Socks5AuthMethod.PASSWORD);
                ctx.writeAndFlush(initialResponse);
            } else {
                Socks5InitialResponse initialResponse = new DefaultSocks5InitialResponse(
                        Socks5AuthMethod.NO_AUTH);
                ctx.writeAndFlush(initialResponse);
            }
        }
    }
}