Examples of SocksCmdRequest


Examples of io.netty.handler.codec.socks.SocksCmdRequest

      return msg.getClass() == SocksInitRequest.class ? Unpooled.wrappedBuffer(Socks5ProxyServerHandlerBuilder.this.init) : Unpooled.wrappedBuffer(Socks5ProxyServerHandlerBuilder.this.cmd);
    }

    private ChannelHandlerContext prepare(final ChannelHandlerContext ctx, Object msg, ChannelFuture future) throws IOException {
      if (msg.getClass() == SocksCmdRequest.class) {
        SocksCmdRequest cmd = SocksCmdRequest.class.cast(msg);
        return Socks5ProxyServerHandlerBuilder.this.exchangerContext.exists(cmd.host()) ? this.activate(Socks5ProxyServerHandlerBuilder.this.exchangerContext.activate(cmd.host()), future, ctx) : this.wait(cmd, ctx);
      }
      return ctx;
    }
View Full Code Here

Examples of io.netty.handler.codec.socks.SocksCmdRequest

            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.nextInboundMessageBuffer().add(socksRequest);
                    ctx.fireInboundBufferUpdated();
                } else {
View Full Code Here

Examples of io.netty.handler.codec.socks.SocksCmdRequest

            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();
View Full Code Here

Examples of org.jboss.netty.handler.codec.socks.SocksCmdRequest

    this.cf = cf;
  }

  @Override
  public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    final SocksCmdRequest socksCmdRequest = (SocksCmdRequest) e.getMessage();
    final Channel inboundChannel = e.getChannel();
    inboundChannel.setReadable(false);

    // Start the connection attempt.
    final ClientBootstrap cb = new ClientBootstrap(cf);
    cb.setOption("keepAlive", true);
    cb.setOption("tcpNoDelay", true);
    cb.setPipelineFactory(new ChannelPipelineFactory() {
      @Override
      public ChannelPipeline getPipeline() throws Exception {
        ChannelPipeline pipeline = Channels.pipeline();
        // 外部server数据转发到client
        pipeline.addLast("outboundChannel", new OutboundHandler(inboundChannel, "out"));
        return pipeline;
      }
    });

    ChannelFuture f = cb.connect(new InetSocketAddress(socksCmdRequest.getHost(), socksCmdRequest.getPort()));

    outboundChannel = f.getChannel();
    ctx.getPipeline().remove(getName());
    f.addListener(new ChannelFutureListener() {
      public void operationComplete(ChannelFuture future) throws Exception {
        if (future.isSuccess()) {
          // client数据转发到外部server
          inboundChannel.getPipeline().addLast("inboundChannel", new OutboundHandler(outboundChannel, "in"));
          inboundChannel.write(new SocksCmdResponse(SocksMessage.CmdStatus.SUCCESS, socksCmdRequest
              .getAddressType()));
          inboundChannel.setReadable(true);
        } else {
          inboundChannel.write(new SocksCmdResponse(SocksMessage.CmdStatus.FAILURE, socksCmdRequest
              .getAddressType()));
          inboundChannel.close();
        }
      }
    });
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.