Examples of Socks5CmdResponse


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

                        @Override
                        public void operationComplete(final Future<Channel> future) throws Exception {
                            final Channel outboundChannel = future.getNow();
                            if (future.isSuccess()) {
                                ctx.channel().writeAndFlush(
                                        new Socks5CmdResponse(Socks5CmdStatus.SUCCESS, request.addressType())
                                ).addListener(new ChannelFutureListener() {
                                            @Override
                                            public void operationComplete(ChannelFuture channelFuture) {
                                                ctx.pipeline().remove(SocksServerConnectHandler.this);
                                                outboundChannel.pipeline().addLast(new RelayHandler(ctx.channel()));
                                                ctx.pipeline().addLast(new RelayHandler(outboundChannel));
                                            }
                                        }
                                );
                            } else {
                                ctx.channel().writeAndFlush(
                                        new Socks5CmdResponse(Socks5CmdStatus.FAILURE, request.addressType()));
                                SocksServerUtils.closeOnFlush(ctx.channel());
                            }
                        }
                    });

            final Channel inboundChannel = ctx.channel();
            b.group(inboundChannel.eventLoop())
                    .channel(NioSocketChannel.class)
                    .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000)
                    .option(ChannelOption.SO_KEEPALIVE, true)
                    .handler(new DirectClientHandler(promise));

            b.connect(request.host(), request.port()).addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    if (future.isSuccess()) {
                        // Connection established use handler provided results
                    } else {
                        // Close the connection if the connection attempt has failed.
                        ctx.channel().writeAndFlush(
                                new Socks5CmdResponse(Socks5CmdStatus.FAILURE, request.addressType()));
                        SocksServerUtils.closeOnFlush(ctx.channel());
                    }
                }
            });
        } else {
View Full Code Here

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

            }

            Socks5CmdRequest req = (Socks5CmdRequest) msg;
            assertThat(req.cmdType(), is(Socks5CmdType.CONNECT));

            Socks5CmdResponse res;
            res = new Socks5CmdResponse(Socks5CmdStatus.SUCCESS, Socks5AddressType.IPv4);
            intermediaryDestination = new InetSocketAddress(req.host(), req.port());

            ctx.write(res);
            ctx.pipeline().remove(Socks5MessageEncoder.class);
View Full Code Here

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

            Socks5CmdRequest req = (Socks5CmdRequest) msg;
            assertThat(req.cmdType(), is(Socks5CmdType.CONNECT));

            ctx.pipeline().addBefore(ctx.name(), "lineDecoder", new LineBasedFrameDecoder(64, false, true));

            Socks5CmdResponse res;
            boolean sendGreeting = false;
            if (!req.host().equals(destination.getHostString()) ||
                       req.port() != destination.getPort()) {
                res = new Socks5CmdResponse(Socks5CmdStatus.FORBIDDEN, Socks5AddressType.IPv4);
            } else {
                res = new Socks5CmdResponse(Socks5CmdStatus.SUCCESS, Socks5AddressType.IPv4);
                sendGreeting = true;
            }

            ctx.write(res);
            ctx.pipeline().remove(Socks5MessageEncoder.class);
View Full Code Here

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

            sendConnectCommand(ctx);
            return false;
        }

        // This should be the last message from the server.
        Socks5CmdResponse res = (Socks5CmdResponse) response;
        if (res.cmdStatus() != Socks5CmdStatus.SUCCESS) {
            throw new ProxyConnectException(exceptionMessage("cmdStatus: " + res.cmdStatus()));
        }

        return true;
    }
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.