Examples of Socks5CmdRequestDecoder


Examples of io.netty.handler.codec.socksx.v5.Socks5CmdRequestDecoder

                switch (((Socks5Request) socksRequest).requestType()) {
                    case INIT: {
                        // auth support example
                        //ctx.pipeline().addFirst(new SocksV5AuthRequestDecoder());
                        //ctx.write(new SocksV5InitResponse(SocksV5AuthScheme.AUTH_PASSWORD));
                        ctx.pipeline().addFirst(new Socks5CmdRequestDecoder());
                        ctx.write(new Socks5InitResponse(Socks5AuthScheme.NO_AUTH));
                        break;
                    }
                    case AUTH:
                        ctx.pipeline().addFirst(new Socks5CmdRequestDecoder());
                        ctx.write(new Socks5AuthResponse(Socks5AuthStatus.SUCCESS));
                        break;
                    case CMD:
                        Socks5CmdRequest socks5CmdRequest = (Socks5CmdRequest) socksRequest;
                        if (socks5CmdRequest.cmdType() == Socks5CmdType.CONNECT) {
View Full Code Here

Examples of io.netty.handler.codec.socksx.v5.Socks5CmdRequestDecoder

        }
    }

    private boolean authenticate(ChannelHandlerContext ctx, Object msg) {
        if (username == null) {
            ctx.pipeline().addBefore("encoder", "decoder", new Socks5CmdRequestDecoder());
            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());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.