Ejemplo n.º 1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="rootCertificateName">Name of root certificate.</param>
        /// <param name="rootCertificateIssuerName">Name of root certificate issuer.</param>
        public ProxyServer(string rootCertificateName, string rootCertificateIssuerName)
        {
            //default values
            ConnectionTimeOutSeconds       = 30;
            CertificateCacheTimeOutMinutes = 60;

            ProxyEndPoints       = new List <ProxyEndPoint>();
            tcpConnectionFactory = new TcpConnectionFactory();
#if NET45
            if (!RunTime.IsRunningOnMono)
            {
                systemProxySettingsManager = new SystemProxyManager();
            }
#endif

            CertificateManager = new CertificateManager(ExceptionFunc);
            if (rootCertificateName != null)
            {
                RootCertificateName = rootCertificateName;
            }

            if (rootCertificateIssuerName != null)
            {
                RootCertificateIssuerName = rootCertificateIssuerName;
            }
        }
        public void CompareProxyAddressReturnedByWebProxyAndWinHttpProxyResolver()
        {
            var proxyManager = new SystemProxyManager();

            try
            {
                compareUrls();

                proxyManager.SetProxy("127.0.0.1", 8000, ProxyProtocolType.Http);
                compareUrls();

                proxyManager.SetProxy("127.0.0.1", 8000, ProxyProtocolType.Https);
                compareUrls();

                proxyManager.SetProxy("127.0.0.1", 8000, ProxyProtocolType.AllHttp);
                compareUrls();

                // for this test you need to add a proxy.pac file to a local webserver
                //function FindProxyForURL(url, host)
                //{
                //    if (shExpMatch(host, "google.com"))
                //    {
                //        return "PROXY 127.0.0.1:8888";
                //    }

                //    return "DIRECT";
                //}

                //proxyManager.SetAutoProxyUrl("http://localhost/proxy.pac");
                //CompareUrls();

                proxyManager.SetProxyOverride("<-loopback>");
                compareUrls();

                proxyManager.SetProxyOverride("<local>");
                compareUrls();

                proxyManager.SetProxyOverride("yahoo.com");
                compareUrls();

                proxyManager.SetProxyOverride("*.local");
                compareUrls();

                proxyManager.SetProxyOverride("http://*.local");
                compareUrls();

                proxyManager.SetProxyOverride("<-loopback>;*.local");
                compareUrls();

                proxyManager.SetProxyOverride("<-loopback>;*.local;<local>");
                compareUrls();
            }
            finally
            {
                proxyManager.RestoreOriginalSettings();
            }
        }
Ejemplo n.º 3
0
 private string getSystemProxyEndPoint()
 {
     try
     {
         return(SystemProxyManager.GetSystemProxyEndPoint());
     }
     catch
     {
         Y_Track.Helpers.YTrackLogger.Log("Cannot read ProxyServer URI");
         return(null);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        ///     Initializes a new instance of ProxyServer class with provided parameters.
        /// </summary>
        /// <param name="rootCertificateName">Name of the root certificate.</param>
        /// <param name="rootCertificateIssuerName">Name of the root certificate issuer.</param>
        /// <param name="userTrustRootCertificate">
        ///     Should fake HTTPS certificate be trusted by this machine's user certificate
        ///     store?
        /// </param>
        /// <param name="machineTrustRootCertificate">Should fake HTTPS certificate be trusted by this machine's certificate store?</param>
        /// <param name="trustRootCertificateAsAdmin">
        ///     Should we attempt to trust certificates with elevated permissions by
        ///     prompting for UAC if required?
        /// </param>
        public ProxyServer(string?rootCertificateName, string?rootCertificateIssuerName,
                           bool userTrustRootCertificate    = true, bool machineTrustRootCertificate = false,
                           bool trustRootCertificateAsAdmin = false)
        {
            BufferPool           = new DefaultBufferPool();
            ProxyEndPoints       = new List <ProxyEndPoint>();
            tcpConnectionFactory = new TcpConnectionFactory(this);
            if (RunTime.IsWindows && !RunTime.IsUwpOnWindows)
            {
                systemProxySettingsManager = new SystemProxyManager();
            }

            CertificateManager = new CertificateManager(rootCertificateName, rootCertificateIssuerName,
                                                        userTrustRootCertificate, machineTrustRootCertificate, trustRootCertificateAsAdmin, ExceptionFunc);
        }
Ejemplo n.º 5
0
        public ProxyServer(string rootCertificateName, string rootCertificateIssuerName)
        {
            RootCertificateName       = rootCertificateName;
            RootCertificateIssuerName = rootCertificateIssuerName;
            //default values
            ConnectionTimeOutSeconds       = 120;
            CertificateCacheTimeOutMinutes = 60;

            ProxyEndPoints              = new List <ProxyEndPoint>();
            tcpConnectionFactory        = new TcpConnectionFactory();
            systemProxySettingsManager  = new SystemProxyManager();
            firefoxProxySettingsManager = new FireFoxProxySettingsManager();

            RootCertificateName       = RootCertificateName ?? "Titanium Root Certificate Authority";
            RootCertificateIssuerName = RootCertificateIssuerName ?? "Titanium";
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Constructor
        /// </summary>
        public ProxyServer()
        {
            //default values
            ConnectionCacheTimeOutMinutes  = 3;
            CertificateCacheTimeOutMinutes = 60;

            ProxyEndPoints              = new List <ProxyEndPoint>();
            tcpConnectionCacheManager   = new TcpConnectionCacheManager();
            systemProxySettingsManager  = new SystemProxyManager();
            firefoxProxySettingsManager = new FireFoxProxySettingsManager();

            RootCertificateName       = RootCertificateName ?? "Titanium Root Certificate Authority";
            RootCertificateIssuerName = RootCertificateIssuerName ?? "Titanium";

            certificateCacheManager = new CertificateManager(RootCertificateIssuerName,
                                                             RootCertificateName);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     Initializes a new instance of ProxyServer class with provided parameters.
        /// </summary>
        /// <param name="rootCertificateName">Name of the root certificate.</param>
        /// <param name="rootCertificateIssuerName">Name of the root certificate issuer.</param>
        /// <param name="userTrustRootCertificate">
        ///     Should fake HTTPS certificate be trusted by this machine's user certificate
        ///     store?
        /// </param>
        /// <param name="machineTrustRootCertificate">Should fake HTTPS certificate be trusted by this machine's certificate store?</param>
        /// <param name="trustRootCertificateAsAdmin">
        ///     Should we attempt to trust certificates with elevated permissions by
        ///     prompting for UAC if required?
        /// </param>
        public ProxyServer(string rootCertificateName, string rootCertificateIssuerName,
                           bool userTrustRootCertificate    = true, bool machineTrustRootCertificate = false,
                           bool trustRootCertificateAsAdmin = false)
        {
            // default values
            ConnectionTimeOutSeconds = 60;

            ProxyEndPoints       = new List <ProxyEndPoint>();
            tcpConnectionFactory = new TcpConnectionFactory();
            if (!RunTime.IsRunningOnMono && RunTime.IsWindows)
            {
                systemProxySettingsManager = new SystemProxyManager();
            }

            CertificateManager = new CertificateManager(rootCertificateName, rootCertificateIssuerName,
                                                        userTrustRootCertificate, machineTrustRootCertificate, trustRootCertificateAsAdmin, ExceptionFunc);
        }
Ejemplo n.º 8
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     YoutubeInterceptEngine.Instance.StopIntercepting();
     SystemProxyManager.StopSystemProxy();
 }
Ejemplo n.º 9
0
 private void _handleUnhandledExceptions(Exception e)
 {
     SystemProxyManager.StopSystemProxy();
     Helpers.YTrackLogger.Log("Unhandled Exception Occured : " + e.Message + "\n\n" + e.StackTrace);
 }