Example usage for io.netty.handler.codec.socksx SocksVersion SOCKS5

List of usage examples for io.netty.handler.codec.socksx SocksVersion SOCKS5

Introduction

In this page you can find the example usage for io.netty.handler.codec.socksx SocksVersion SOCKS5.

Prototype

SocksVersion SOCKS5

To view the source code for io.netty.handler.codec.socksx SocksVersion SOCKS5.

Click Source Link

Document

SOCKS protocol version 5

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 va  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);
            }
        }
    }
}