Exemplo n.º 1
0
        public static void Main(String[] args)
        {
            XmlConfigurator.Configure();

            var options = new CommandlineOptions();

            if (!Parser.Default.ParseArguments(args, options))
            {
                return;
            }

            try
            {
                var httpProxyServer = options.HttpPort == 0
                    ? new HttpProxyServer(options.Host, new HttpProxy())
                    : new HttpProxyServer(options.Host, options.HttpPort, new HttpProxy());
                httpProxyServer.Log += OnLog;

                var sslProxyServer = options.SslPort == 0
                    ? new HttpProxyServer(options.Host, new SslProxy(Certificate))
                    : new HttpProxyServer(options.Host, options.SslPort, new SslProxy(Certificate));

                WaitHandle.WaitAll(new[]
                {
                    httpProxyServer.Start(),
                    sslProxyServer.Start()
                });

                Console.WriteLine("Started HTTP proxy on {0}", httpProxyServer.ProxyEndPoint);
                Console.WriteLine("Started SSL proxy on {0}", sslProxyServer.ProxyEndPoint);
                Console.WriteLine("Type 'stop' in order to shutdown");

                while (Console.ReadLine() != StopCommad)
                {
                    Thread.Sleep(TimeSpan.FromSeconds(1));
                }

                Console.WriteLine("shutting down...");

                httpProxyServer.Stop();
                sslProxyServer.Stop();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemplo n.º 2
0
        public static void Main(String[] args)
        {
            XmlConfigurator.Configure();

            var options = new CommandlineOptions();

            if (!Parser.Default.ParseArguments(args, options))
            {
                return;
            }

            try
            {
                var httpProxyServer = options.HttpPort == 0
                    ? new HttpProxyServer(options.Host, new HttpProxy())
                    : new HttpProxyServer(options.Host, options.HttpPort, new HttpProxy());

                var sslProxyServer = options.SslPort == 0
                    ? new HttpProxyServer(options.Host, new SslProxy(Certificate))
                    : new HttpProxyServer(options.Host, options.SslPort, new SslProxy(Certificate));

                WaitHandle.WaitAll(new[]
                {
                    httpProxyServer.Start(),
                    sslProxyServer.Start()
                });

                Console.WriteLine("Started HTTP proxy on {0}", httpProxyServer.ProxyEndPoint);
                Console.WriteLine("Started SSL proxy on {0}", sslProxyServer.ProxyEndPoint);
                Console.WriteLine("Type 'stop' in order to shutdown");

                while (Console.ReadLine() != StopCommad)
                {
                    Thread.Sleep(TimeSpan.FromSeconds(1));
                }

                Console.WriteLine("shutting down...");

                httpProxyServer.Stop();
                sslProxyServer.Stop();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }