Ejemplo n.º 1
0
        /// <summary>
        /// Starts the proxy server on both IPV4 and IPV6 address space.
        /// </summary>
        /// <param name="numThreads">
        /// An optional value that can be used to set the number of threads that the underlying
        /// packet diversion system will use for packet IO. Defaults to zero. If less than or equal
        /// to zero, the diverter should automatically choose to use one thread per logical core.
        /// However, given that diverters are platform specific, this is not guaranteed.
        /// </param>
        /// <exception cref="NullReferenceException">
        /// In the event that the internal kestrel engine doesn't properly initialize, this method
        /// will throw.
        /// </exception>
        public void Start(int numThreads = 0)
        {
            lock (_startStopLock)
            {
                if (_running)
                {
                    return;
                }

                _hosts = new List <IWebHost>()
                {
                    CreateHost(false),
                    CreateHost(true)
                };

                _diverter = CreateDiverter(
                    V4HttpEndpoint,
                    V4HttpsEndpoint,
                    V6HttpEndpoint,
                    V6HttpsEndpoint
                    );

                _diverter.ConfirmDenyFirewallAccess = (procPath) =>
                {
                    return(_fwCallback.Invoke(procPath));
                };

                _diverter.Start(numThreads);

                _running = true;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts the proxy server on both IPV4 and IPV6 address space.
        /// </summary>
        public void Start()
        {
            lock (m_startStopLock)
            {
                if (m_running)
                {
                    return;
                }

                m_hosts = new List <IWebHost>()
                {
                    CreateHost(false),
                    CreateHost(true)
                };

                m_diverter = CreateDiverter(
                    m_v4HttpListenerEp,
                    m_v4HttpsListenerEp,
                    m_v6HttpListenerEp,
                    m_v6HttpsListenerEp
                    );

                m_diverter.ConfirmDenyFirewallAccess = (procPath) =>
                {
                    return(m_fwCallback.Invoke(procPath));
                };

                m_diverter.Start(0);

                m_running = true;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Starts the proxy server on both IPV4 and IPV6 address space.
        /// </summary>
        /// <param name="numThreads">
        /// An optional value that can be used to set the number of threads that the underlying
        /// packet diversion system will use for packet IO. Defaults to zero. If less than or equal
        /// to zero, the diverter should automatically choose to use one thread per logical core.
        /// However, given that diverters are platform specific, this is not guaranteed.
        /// </param>
        /// <exception cref="NullReferenceException">
        /// In the event that the internal kestrel engine doesn't properly initialize, this method
        /// will throw.
        /// </exception>
        public void Start(int numThreads = 0)
        {
            lock (_startStopLock)
            {
                if (_running)
                {
                    return;
                }

                // Create the public, v4 proxy.

                var publicV4Startup = new PublicServerStartup(null, _httpResponseFactory);
                var publicV4Host    = CreateHost <PublicServerStartup>(false, false, out IPEndPoint v4HttpEndpoint, publicV4Startup);

                V4HttpEndpoint = v4HttpEndpoint;

                // Create the public, v6 proxy.

                var publicV6Startup = new PublicServerStartup(null, _httpResponseFactory);
                var publicV6Host    = CreateHost <PublicServerStartup>(false, true, out IPEndPoint v6HttpEndpoint, publicV6Startup);

                V6HttpEndpoint = v6HttpEndpoint;

                // Create the private, v4 replay proxy
                var privateV4Startup = new PrivateServerStartup(null, _replayResponseFactory);
                var privateV4Host    = CreateHost <PrivateServerStartup>(true, false, out IPEndPoint privateV4HttpEndpoint, privateV4Startup);

                _replayResponseFactory.V4HttpEndpoint  = privateV4HttpEndpoint;
                _replayResponseFactory.V4HttpsEndpoint = privateV4HttpEndpoint;

                _hosts = new List <IWebHost>()
                {
                    publicV4Host,
                    publicV6Host,
                    privateV4Host
                };

                _diverter = CreateDiverter(
                    V4HttpEndpoint,
                    V4HttpEndpoint,
                    V6HttpEndpoint,
                    V6HttpEndpoint
                    );

                _diverter.ConfirmDenyFirewallAccess = (procPath) =>
                {
                    return(_fwCallback.Invoke(procPath));
                };

                _diverter.Start(numThreads);

                _running = true;
            }
        }