io.netty.handler.codec.socks.SocksInitRequestDecoder Java Examples

The following examples show how to use io.netty.handler.codec.socks.SocksInitRequestDecoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XClient.java    From AgentX with Apache License 2.0 5 votes vote down vote up
public void start() {
    Configuration config = Configuration.INSTANCE;
    InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
    bossGroup = new NioEventLoopGroup(1);
    workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap bootstrap = new ServerBootstrap();
        bootstrap.group(bossGroup, workerGroup)
                .channel(NioServerSocketChannel.class)
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    protected void initChannel(SocketChannel socketChannel) throws Exception {
                        socketChannel.pipeline()
                                .addLast("logging", new LoggingHandler(LogLevel.DEBUG))
                                .addLast(new SocksInitRequestDecoder())
                                .addLast(new SocksMessageEncoder())
                                .addLast(new Socks5Handler())
                                .addLast(Status.TRAFFIC_HANDLER);
                    }
                });
        log.info("\tStartup {}-{}-client [{}{}]", Constants.APP_NAME, Constants.APP_VERSION, config.getMode(), config.getMode().equals("socks5") ? "" : ":" + config.getProtocol());
        new Thread(() -> new UdpServer().start()).start();
        ChannelFuture future = bootstrap.bind(config.getLocalHost(), config.getLocalPort()).sync();
        future.addListener(future1 -> log.info("\tTCP listening at {}:{}...", config.getLocalHost(), config.getLocalPort()));
        future.channel().closeFuture().sync();
    } catch (Exception e) {
        log.error("\tSocket bind failure ({})", e.getMessage());
    } finally {
        log.info("\tShutting down");
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
Example #2
Source File: SocksServerInitializer.java    From NSS with Apache License 2.0 5 votes vote down vote up
@Override
public void initChannel(SocketChannel socketChannel) throws Exception {
	ChannelPipeline p = socketChannel.pipeline();
	p.addLast(new SocksInitRequestDecoder());
	p.addLast(socksMessageEncoder);
	p.addLast(socksServerHandler);
	p.addLast(trafficHandler);
}
 
Example #3
Source File: SocksServerInitializer.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
public void initChannel(SocketChannel socketChannel) throws Exception {
    ChannelPipeline p = socketChannel.pipeline();
    p.addLast(new SocksInitRequestDecoder());
    p.addLast(socksMessageEncoder);
    p.addLast(socksServerHandler);
}
 
Example #4
Source File: Socks5ProxyServerHandlerChannelInitializer.java    From sissi with Apache License 2.0 4 votes vote down vote up
@Override
protected void initChannel(SocketChannel ch) throws Exception {
	ch.pipeline().addLast(new SocksInitRequestDecoder()).addLast(new SocksCmdRequestDecoder()).addLast(new IdleStateHandler(this.idleRead, this.idleWrite, this.idleAll)).addLast(this.channelHandlerBuilder.build());
}