Beispiel #1
0
        public ServerChannel Create()
        {
            TcpServerSocketChannel socketchannel = new TcpServerSocketChannel();

            _cg.Add(socketchannel);
            return(socketchannel);
        }
Beispiel #2
0
        /**
         * Starts a new proxy server with disabled authentication for testing purpose.
         *
         * @param useSsl {@code true} if and only if implicit SSL is enabled
         * @param testMode the test mode
         * @param username the expected username. If the client tries to authenticate with a different username, this server
         * will fail the authentication request.
         * @param password the expected password. If the client tries to authenticate with a different password, this server
         * will fail the authentication request.
         * @param destination the expected destination. If the client requests proxying to a different destination, this
         * server will reject the connection request.
         */
        protected ProxyServer(bool useSsl, TestMode testMode, EndPoint destination, string username, string password)
        {
            TestMode    = testMode;
            Destination = destination;
            Username    = username;
            Password    = password;

            var b = new ServerBootstrap()
                    .Channel <TcpServerSocketChannel>()
                    .Group(ProxyHandlerTest.Group)
                    .ChildHandler(new ActionChannelInitializer <ISocketChannel>(ch =>
            {
                var p = ch.Pipeline;
                if (useSsl)
                {
                    p.AddLast(TlsHandler.Server(TestResourceHelper.GetTestCertificate()));
                }

                Configure(ch);
            }));

            _ch = (TcpServerSocketChannel)b.BindAsync(IPAddress.Loopback, 0).Result;
        }
Beispiel #3
0
        public async Task TestIsActiveFalseAfterClose()
        {
            var             serverSocketChannel = new TcpServerSocketChannel();
            IEventLoopGroup group = new MultithreadEventLoopGroup(1);

            try
            {
                await group.RegisterAsync(serverSocketChannel);

                await serverSocketChannel.BindAsync(new IPEndPoint(IPAddress.IPv6Loopback, 0));

                Assert.True(serverSocketChannel.IsActive);
                Assert.True(serverSocketChannel.IsOpen);
                await serverSocketChannel.CloseAsync();

                Assert.False(serverSocketChannel.IsOpen);
                Assert.False(serverSocketChannel.IsActive);
            }
            finally
            {
                await group.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1));
            }
        }
 public CustTcpServerSocketChannelUnsafe(TcpServerSocketChannel channel)
     : base(channel)
 {
 }