Java 类io.netty.handler.codec.socks.SocksInitResponse 实例源码

项目:NSS    文件:SocksServerHandler.java   
@Override
public void channelRead0(ChannelHandlerContext ctx,
        SocksRequest socksRequest) throws Exception {
    switch (socksRequest.requestType()) {
    case INIT: {
        logger.info("localserver init");
        ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
        ctx.write(new SocksInitResponse(SocksAuthScheme.NO_AUTH));
        break;
    }
    case AUTH:
        ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
        ctx.write(new SocksAuthResponse(SocksAuthStatus.SUCCESS));
        break;
    case CMD:
        SocksCmdRequest req = (SocksCmdRequest) socksRequest;
        if (req.cmdType() == SocksCmdType.CONNECT) {
            logger.info("localserver connect");
            ctx.pipeline().addLast(new SocksServerConnectHandler(config));
            ctx.pipeline().remove(this);
            ctx.fireChannelRead(socksRequest);
        } else {
            ctx.close();
        }
        break;
    case UNKNOWN:
        ctx.close();
        break;
    }
}
项目:ss-java    文件:SocksServerHandler.java   
@Override
public void channelRead0(ChannelHandlerContext ctx,
        SocksRequest socksRequest) throws Exception {
    switch (socksRequest.requestType()) {
        case INIT: {
            ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
            ctx.write(new SocksInitResponse(SocksAuthScheme.NO_AUTH));
            break;
        }
        case AUTH:
            ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
            ctx.write(new SocksAuthResponse(SocksAuthStatus.SUCCESS));
            break;
        case CMD:
            SocksCmdRequest req = (SocksCmdRequest) socksRequest;
            if (req.cmdType() == SocksCmdType.CONNECT) {
                ctx.pipeline().addLast(new ShadowsocksServerConnectHandler());
                ctx.pipeline().remove(this);
                ctx.fireChannelRead(socksRequest);
            } else {
                ctx.close();
            }
            break;
        case UNKNOWN:
            ctx.close();
            break;
    }
}
项目:netty4.0.27Learn    文件:SocksServerHandler.java   
@Override
public void channelRead0(ChannelHandlerContext ctx, SocksRequest socksRequest) throws Exception {
    switch (socksRequest.requestType()) {
        case INIT: {
            // auth support example
            //ctx.pipeline().addFirst(new SocksAuthRequestDecoder());
            //ctx.write(new SocksInitResponse(SocksAuthScheme.AUTH_PASSWORD));
            ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
            ctx.write(new SocksInitResponse(SocksAuthScheme.NO_AUTH));
            break;
        }
        case AUTH:
            ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
            ctx.write(new SocksAuthResponse(SocksAuthStatus.SUCCESS));
            break;
        case CMD:
            SocksCmdRequest req = (SocksCmdRequest) socksRequest;
            if (req.cmdType() == SocksCmdType.CONNECT) {
                ctx.pipeline().addLast(new SocksServerConnectHandler());
                ctx.pipeline().remove(this);
                ctx.fireChannelRead(socksRequest);
            } else {
                ctx.close();
            }
            break;
        case UNKNOWN:
            ctx.close();
            break;
    }
}
项目:netty4study    文件:SocksServerHandler.java   
@Override
    public void channelRead0(ChannelHandlerContext ctx, SocksRequest socksRequest) throws Exception {
        switch (socksRequest.requestType()) {
            case INIT: {
//                auth support example
//                ctx.pipeline().addFirst("socksAuthRequestDecoder",new SocksAuthRequestDecoder());
//                ctx.write(new SocksInitResponse(SocksMessage.SocksAuthScheme.AUTH_PASSWORD));
                ctx.pipeline().addFirst(SocksCmdRequestDecoder.getName(), new SocksCmdRequestDecoder());
                ctx.write(new SocksInitResponse(SocksAuthScheme.NO_AUTH));
                break;
            }
            case AUTH:
                ctx.pipeline().addFirst(SocksCmdRequestDecoder.getName(), new SocksCmdRequestDecoder());
                ctx.write(new SocksAuthResponse(SocksAuthStatus.SUCCESS));
                break;
            case CMD:
                SocksCmdRequest req = (SocksCmdRequest) socksRequest;
                if (req.cmdType() == SocksCmdType.CONNECT) {
                    ctx.pipeline().addLast(SocksServerConnectHandler.getName(), new SocksServerConnectHandler());
                    ctx.pipeline().remove(this);
                    ctx.fireChannelRead(socksRequest);
                } else {
                    ctx.close();
                }
                break;
            case UNKNOWN:
                ctx.close();
                break;
        }
    }
项目:netty-netty-5.0.0.Alpha1    文件:SocksServerHandler.java   
@Override
    public void messageReceived(ChannelHandlerContext ctx, SocksRequest socksRequest) throws Exception {
        switch (socksRequest.requestType()) {
            case INIT: {
//                auth support example
//                ctx.pipeline().addFirst("socksAuthRequestDecoder",new SocksAuthRequestDecoder());
//                ctx.write(new SocksInitResponse(SocksMessage.SocksAuthScheme.AUTH_PASSWORD));
                ctx.pipeline().addFirst(SocksCmdRequestDecoder.getName(), new SocksCmdRequestDecoder());
                ctx.write(new SocksInitResponse(SocksAuthScheme.NO_AUTH));
                break;
            }
            case AUTH:
                ctx.pipeline().addFirst(SocksCmdRequestDecoder.getName(), new SocksCmdRequestDecoder());
                ctx.write(new SocksAuthResponse(SocksAuthStatus.SUCCESS));
                break;
            case CMD:
                SocksCmdRequest req = (SocksCmdRequest) socksRequest;
                if (req.cmdType() == SocksCmdType.CONNECT) {
                    ctx.pipeline().addLast(SocksServerConnectHandler.getName(), new SocksServerConnectHandler());
                    ctx.pipeline().remove(this);
                    ctx.fireChannelRead(socksRequest);
                } else {
                    ctx.close();
                }
                break;
            case UNKNOWN:
                ctx.close();
                break;
        }
    }
项目:sissi    文件:Socks5ProxyServerHandlerBuilder.java   
private ByteBuf buildInit() {
    ByteBuf buf = Unpooled.buffer();
    new SocksInitResponse(SocksAuthScheme.NO_AUTH).encodeAsByteBuf(buf);
    return buf;
}