Search in sources :

Example 1 with SocksPortUnificationServerHandler

use of io.netty.handler.codec.socksx.SocksPortUnificationServerHandler in project cdap by caskdata.

the class ServiceSocksProxy method startUp.

@Override
protected void startUp() throws Exception {
    ServerBootstrap bootstrap = new ServerBootstrap();
    // We don't perform any blocking task in the proxy, only IO relying, hence doesn't need large amount of threads.
    eventLoopGroup = new NioEventLoopGroup(10, Threads.createDaemonThreadFactory("service-socks-proxy-%d"));
    bootstrap.group(eventLoopGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() {

        @Override
        protected void initChannel(SocketChannel ch) {
            channelGroup.add(ch);
            ch.pipeline().addLast(new SocksPortUnificationServerHandler()).addLast(new ServiceSocksServerHandler(discoveryServiceClient, authenticator));
        }
    });
    Channel serverChannel = bootstrap.bind(InetAddress.getLoopbackAddress(), 0).sync().channel();
    bindAddress = (InetSocketAddress) serverChannel.localAddress();
    channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE);
    channelGroup.add(serverChannel);
    LOG.info("Runtime service socks proxy started on {}", bindAddress);
}
Also used : DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) SocketChannel(io.netty.channel.socket.SocketChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) Channel(io.netty.channel.Channel) SocketChannel(io.netty.channel.socket.SocketChannel) SocksPortUnificationServerHandler(io.netty.handler.codec.socksx.SocksPortUnificationServerHandler) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Example 2 with SocksPortUnificationServerHandler

use of io.netty.handler.codec.socksx.SocksPortUnificationServerHandler in project cdap by cdapio.

the class ServiceSocksProxy method startUp.

@Override
protected void startUp() throws Exception {
    ServerBootstrap bootstrap = new ServerBootstrap();
    // We don't perform any blocking task in the proxy, only IO relying, hence doesn't need large amount of threads.
    eventLoopGroup = new NioEventLoopGroup(10, Threads.createDaemonThreadFactory("service-socks-proxy-%d"));
    bootstrap.group(eventLoopGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() {

        @Override
        protected void initChannel(SocketChannel ch) {
            channelGroup.add(ch);
            ch.pipeline().addLast(new SocksPortUnificationServerHandler()).addLast(new ServiceSocksServerHandler(discoveryServiceClient, authenticator));
        }
    });
    Channel serverChannel = bootstrap.bind(InetAddress.getLoopbackAddress(), 0).sync().channel();
    bindAddress = (InetSocketAddress) serverChannel.localAddress();
    channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE);
    channelGroup.add(serverChannel);
    LOG.info("Runtime service socks proxy started on {}", bindAddress);
}
Also used : DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) SocketChannel(io.netty.channel.socket.SocketChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) Channel(io.netty.channel.Channel) SocketChannel(io.netty.channel.socket.SocketChannel) SocksPortUnificationServerHandler(io.netty.handler.codec.socksx.SocksPortUnificationServerHandler) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Aggregations

ServerBootstrap (io.netty.bootstrap.ServerBootstrap)2 Channel (io.netty.channel.Channel)2 DefaultChannelGroup (io.netty.channel.group.DefaultChannelGroup)2 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)2 SocketChannel (io.netty.channel.socket.SocketChannel)2 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)2 SocksPortUnificationServerHandler (io.netty.handler.codec.socksx.SocksPortUnificationServerHandler)2