Exemplo n.º 1
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
        }
Exemplo n.º 2
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);
        }