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

项目:mockserver    文件:PortUnificationHandler.java   
private boolean isSocks(ByteBuf msg) {
    switch (SocksProtocolVersion.valueOf(msg.getByte(msg.readerIndex()))) {
        case SOCKS5:
        case SOCKS4a:
            break;
        default:
            return false;
    }

    byte numberOfAuthenticationMethods = msg.getByte(msg.readerIndex() + 1);
    for (int i = 0; i < numberOfAuthenticationMethods; i++) {
        switch (SocksAuthScheme.valueOf(msg.getByte(msg.readerIndex() + 1 + i))) {
            case NO_AUTH:
            case AUTH_PASSWORD:
            case AUTH_GSSAPI:
                break;
            default:
                return false;
        }
    }
    return true;
}
项目: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;
}