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

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

Introduction

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

Prototype

@Override
    public final SocksVersion version() 

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 . java  2s  .c o m
    } 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);
            }
        }
    }
}