Beispiel #1
0
        public static bool Start()
        {
            listener = new TcpListener(IPAddress.Any, 0);
            listener.Start();
            listenerThread = new Thread(new ParameterizedThreadStart(Listen));
            listenerThread.IsBackground = true;
            ShouldListen = true;
            listenerThread.Start(listener);

            if (SetAsSystemProxy)
            {
                SystemProxyHelper.EnableProxyHTTP("localhost", ListeningPort);
                FireFoxHelper.AddFirefox();


                if (EnableSSL)
                {
                    RootCertificateName = RootCertificateName == null ? "Titanium_Proxy_Test_Root" : RootCertificateName;

                    bool certTrusted = CertManager.CreateTrustedRootCertificate();
                    //If certificate was trusted by the machine
                    if (certTrusted)
                    {
                        SystemProxyHelper.EnableProxyHTTPS("localhost", ListeningPort);
                    }
                }
            }

            return(true);
        }
Beispiel #2
0
        public static bool Start()
        {
            listener = new TcpListener(IPAddress.Any, 0);
            listener.Start();
            listenerThread = new Thread(new ParameterizedThreadStart(Listen));
            listenerThread.IsBackground = true;
            ShouldListen = true;
            listenerThread.Start(listener);

            if (SetAsSystemProxy)
            {
                SystemProxyHelper.EnableProxyHTTP("localhost", ListeningPort);
                FireFoxHelper.AddFirefox();


                if (EnableSSL)
                {
                    RootCertificateName = RootCertificateName == null ? "DO_NOT_TRUST_FiddlerRoot" : RootCertificateName;

                    bool certTrusted = CertManager.CreateTrustedRootCertificate();
                    if (!certTrusted)
                    {
                        // The user didn't want to install the self-signed certificate to the root store.
                    }

                    SystemProxyHelper.EnableProxyHTTPS("localhost", ListeningPort);
                }
            }

            return(true);
        }
Beispiel #3
0
        public static void SetAsSystemHttpsProxy(ExplicitProxyEndPoint endPoint)
        {
            VerifyProxy(endPoint);

            if (!endPoint.EnableSsl)
            {
                throw new Exception("Endpoint do not support Https connections");
            }

            //clear any settings previously added
            ProxyEndPoints.OfType <ExplicitProxyEndPoint>().ToList().ForEach(x => x.IsSystemHttpsProxy = false);


            //If certificate was trusted by the machine
            if (certTrusted)
            {
                SystemProxyHelper.SetHttpsProxy(
                    Equals(endPoint.IpAddress, IPAddress.Any) | Equals(endPoint.IpAddress, IPAddress.Loopback) ? "127.0.0.1" : endPoint.IpAddress.ToString(),
                    endPoint.Port);
            }

            endPoint.IsSystemHttpsProxy = true;

#if !DEBUG
            FireFoxHelper.AddFirefox();
#endif
            Console.WriteLine("Set endpoint at Ip {1} and port: {2} as System HTTPS Proxy", endPoint.GetType().Name, endPoint.IpAddress, endPoint.Port);
        }
Beispiel #4
0
        public static void EnableProxy()
        {
#if !DEBUG
            //if(System.Environment.OSVersion.Version <=
            //if (System.Environment.OSVersion.Version.Major <= 6 && System.Environment.OSVersion.Version.Minor <= 1)
            //{
            //    log.Info("Enabel Proxy Win7!");
            //    try { ProxyRoutines.SetProxy("http=127.0.0.1:8090"); }
            //    catch (Exception exp) { log.Error(exp.ToString()); }
            //}
            //else
            {
                log.Info("Enabel Proxy!");
                try
                {
                    if (!GetProxy())
                    {
                        if (System.Environment.OSVersion.Version.Major <= 6 && System.Environment.OSVersion.Version.Minor <= 1)
                        {
                            TrollProxyHelper.SetHttpProxy("127.0.0.1", 8090);
                        }
                        else
                        {
                            SystemProxyHelper.SetHttpProxy("127.0.0.1", 8090);
                        }
                        FireFoxHelper.AddFirefox();
                    }
                }
                catch (Exception e)
                {
                    log.Error(e.ToString());
                }
            }
#endif
        }
Beispiel #5
0
        private void TurnOnProxy()
        {
#if !DEBUG
            //ProxyRoutines.SetProxy("http=127.0.0.1:8090", null);
            SystemProxyHelper.EnableProxyHTTP("127.0.0.1", 8090);
            FireFoxHelper.AddFirefox();
#endif
            //notify_icon_main.Icon = Properties.Resources.on;
            tool_strip_menu_item_toggle_onff.Checked = true;
            //toggleOnOffButton.Image = Properties.Resources.powerblue_small;
            Properties.Settings.Default.isProtected = true;
            Properties.Settings.Default.Save();
            //同时设置
            TurnOnAutoStart();
        }
Beispiel #6
0
        public static void SetAsSystemHttpProxy(ExplicitProxyEndPoint endPoint)
        {
            VerifyProxy(endPoint);

            //clear any settings previously added
            ProxyEndPoints.OfType <ExplicitProxyEndPoint>().ToList().ForEach(x => x.IsSystemHttpProxy = false);

            SystemProxyHelper.SetHttpProxy(
                Equals(endPoint.IpAddress, IPAddress.Any) | Equals(endPoint.IpAddress, IPAddress.Loopback) ? "127.0.0.1" : endPoint.IpAddress.ToString(), endPoint.Port);

            endPoint.IsSystemHttpProxy = true;
#if !DEBUG
            FireFoxHelper.AddFirefox();
#endif
            Console.WriteLine("Set endpoint at Ip {1} and port: {2} as System HTTPS Proxy", endPoint.GetType().Name, endPoint.IpAddress, endPoint.Port);
        }
        public static bool Start()
        {
            _listener = new TcpListener(ListeningIpAddress, ListeningPort);
            _listener.Start();

            ListeningPort = ((IPEndPoint)_listener.LocalEndpoint).Port;
            // accept clients asynchronously
            _listener.BeginAcceptTcpClient(OnAcceptConnection, _listener);

            var certTrusted = false;

            if (EnableSsl)
            {
                certTrusted = CertManager.CreateTrustedRootCertificate();
            }

            if (SetAsSystemProxy)
            {
                SystemProxyHelper.EnableProxyHttp(
                    Equals(ListeningIpAddress, IPAddress.Any) ? "127.0.0.1" : ListeningIpAddress.ToString(), ListeningPort);

#if !DEBUG
                FireFoxHelper.AddFirefox();
#endif


                if (EnableSsl)
                {
                    RootCertificateName = RootCertificateName ?? "Titanium_Proxy_Test_Root";

                    //If certificate was trusted by the machine
                    if (certTrusted)
                    {
                        SystemProxyHelper.EnableProxyHttps(
                            Equals(ListeningIpAddress, IPAddress.Any) ? "127.0.0.1" : ListeningIpAddress.ToString(),
                            ListeningPort);
                    }
                }
            }

            return(true);
        }