SslEnabledNettyClientFactory extends NettyKeyedPoolClientFactory { @Override public PooledObject<NettyClient> makeObject(Endpoint key) { ProxyEndpoint endpoint = (ProxyEndpoint) key; ChannelFuture f = getBootstrap(endpoint).connect(key.getHost(), key.getPort()); NettyClient nettyClient = new AsyncNettyClient(f, key); f.channel().attr(NettyClientHandler.KEY_CLIENT).set(nettyClient); return new DefaultPooledObject<>(nettyClient); } SslEnabledNettyClientFactory(ResourceManager resourceManager);  SslEnabledNettyClientFactory(int eventLoopThreads, ResourceManager resourceManager); @Override PooledObject<NettyClient> makeObject(Endpoint key);  }
@Test public void testMakeObject() throws Exception { Server localServer = startEchoServer(); int tlsPort = server.getConfig().frontendTlsPort(); PooledObject<NettyClient> clientPooledObject = factory.makeObject(new DefaultProxyEndpoint(ProxyEndpoint.PROXY_SCHEME.PROXYTLS + ": clientPooledObject.getObject().sendRequest(Unpooled.copiedBuffer(String.format("+PROXY ROUTE TCP: sleep(1000); }
@Test public void testTLSHandShakeError() throws Exception { int tlsPort = server.getConfig().frontendTlsPort(); PooledObject<NettyClient> clientPooledObject = factory.makeObject(new DefaultProxyEndpoint(ProxyEndpoint.PROXY_SCHEME.PROXYTLS + ": clientPooledObject.getObject().sendRequest(Unpooled.copiedBuffer(("+PROXY MONITOR PingStats\r\n").getBytes())); sleep(1000); }
@Ignore @Test public void manuallyTestFWS() throws Exception { PooledObject<NettyClient> clientPooledObject = factory.makeObject(new DefaultProxyEndpoint(ProxyEndpoint.PROXY_SCHEME.PROXYTLS + ": clientPooledObject.getObject().sendRequest( Unpooled.copiedBuffer(("+PROXY MONITOR PingStats\r\n+PROXY MONITOR TunnelStats\r\n+PROXY MONITOR SocketStats\r\n").getBytes()), new ByteBufReceiver() { @Override public RECEIVER_RESULT receive(Channel channel, ByteBuf byteBuf) { logger.info("{}", ByteBufUtils.readToString(byteBuf)); return RECEIVER_RESULT.SUCCESS; } @Override public void clientClosed(NettyClient nettyClient) { } }); sleep(1000); }
@Test public void manuallyTestTimeoutLog() throws Exception { PooledObject<NettyClient> clientPooledObject = factory.makeObject(new DefaultProxyEndpoint(ProxyEndpoint.PROXY_SCHEME.PROXYTLS + ": clientPooledObject.getObject().sendRequest( Unpooled.copiedBuffer(("+PROXY MONITOR PingStats\r\n+PROXY MONITOR TunnelStats\r\n+PROXY MONITOR SocketStats\r\n").getBytes()), new ByteBufReceiver() { @Override public RECEIVER_RESULT receive(Channel channel, ByteBuf byteBuf) { logger.info("{}", ByteBufUtils.readToString(byteBuf)); return RECEIVER_RESULT.SUCCESS; } @Override public void clientClosed(NettyClient nettyClient) { } }); sleep(1000); }