Esempio n. 1
0
        private void ButtonReloadFilters_Click(object sender, RoutedEventArgs e)
        {
            var oldCur = Cursor;

            Cursor = Cursors.Wait;

            _filterMatchFinder          = new Models.FilterMatchFinder(FilterSettingsFile);
            _filterMatchFinderExclusive = new Models.FilterMatchFinder(FilterExclusiveSettingsFile);
            tbFilters.Text = _filterMatchInclusive ? _filterMatchFinder.FiltersInfo : _filterMatchFinderExclusive.FiltersInfo;

            _nodecryptSSLMatchFinder          = new Models.FilterMatchFinder(NodecryptSSLSettingsFile);
            _nodecryptSSLMatchFinderExclusive = new Models.FilterMatchFinder(NodecryptSSLExclusiveSettingsFile);
            tbNodecryptSSL.Text = _nodecryptSSLMatchInclusive ? _nodecryptSSLMatchFinder.FiltersInfo : _nodecryptSSLMatchFinderExclusive.FiltersInfo;

            _saveFilterMatchFinder          = new Models.FilterMatchFinder(SaveFilterSettingsFile);
            _saveFilterMatchFinderExclusive = new Models.FilterMatchFinder(SaveFilterExclusiveSettingsFile);
            tbSaveFilter.Text = _saveMatchInclusive ? _saveFilterMatchFinder.FiltersInfo : _saveFilterMatchFinderExclusive.FiltersInfo;



            Cursor = oldCur;
        }
Esempio n. 2
0
        public MainWindow()
        {
#if DEBUG
            SaveTrafficDataPath = Path.Combine(Environment.CurrentDirectory, "Temp");
#else
            if (string.IsNullOrEmpty(Properties.Settings.Default.SaveDataPath))
            {
                SaveTrafficDataPath = Path.Combine("h:\\Temp", "TitaniumWebProxy");
            }
            else
            {
                SaveTrafficDataPath = Properties.Settings.Default.SaveDataPath;
            }
#endif
            _filterMatchInclusive       = Properties.Settings.Default.filterMatchInclusive;
            _nodecryptSSLMatchInclusive = Properties.Settings.Default.nodecryptSSLMatchInclusive;
            _saveMatchInclusive         = Properties.Settings.Default.saveMatchInclusive;

            FilterSettingsFile       = "filter.config";
            NodecryptSSLSettingsFile = "NodecryptSSL.config";
            SaveFilterSettingsFile   = "save_filter.config";

            FilterExclusiveSettingsFile       = "filterExclusive.config";
            NodecryptSSLExclusiveSettingsFile = "NodecryptSSLExclusive.config";
            SaveFilterExclusiveSettingsFile   = "save_filterExclusive.config";

            _filterMatchFinder       = new Models.FilterMatchFinder(FilterSettingsFile);
            _nodecryptSSLMatchFinder = new Models.FilterMatchFinder(NodecryptSSLSettingsFile);
            _saveFilterMatchFinder   = new Models.FilterMatchFinder(SaveFilterSettingsFile);

            _filterMatchFinderExclusive       = new Models.FilterMatchFinder(FilterExclusiveSettingsFile);
            _nodecryptSSLMatchFinderExclusive = new Models.FilterMatchFinder(NodecryptSSLExclusiveSettingsFile);
            _saveFilterMatchFinderExclusive   = new Models.FilterMatchFinder(SaveFilterExclusiveSettingsFile);


            #region TEST

            string testUrl = "http://www.youtube.com:443";
            var    res     = _nodecryptSSLMatchFinder.HasMatches(testUrl);

            testUrl = "http://www.youtube.com:443/";
            res     = _nodecryptSSLMatchFinder.HasMatches(testUrl);

            testUrl = "https://www.youtube.com:443/";
            res     = _nodecryptSSLMatchFinder.HasMatches(testUrl);

            testUrl = "www.youtube.com:443";
            res     = _nodecryptSSLMatchFinder.HasMatches(testUrl);

            testUrl = "https://www.youtube.com/youtubei/v1/log_event?alt=json&key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
            res     = _filterMatchFinder.HasMatches(testUrl);

            #endregion TEST

            _nodecryptSSLMatchFinder = new Models.FilterMatchFinder(NodecryptSSLSettingsFile);
            _filterMatchFinder       = new Models.FilterMatchFinder(FilterSettingsFile);



            proxyServer = new ProxyServer();
            //proxyServer.CertificateManager.CertificateEngine = CertificateEngine.DefaultWindows;

            ////Set a password for the .pfx file
            //proxyServer.CertificateManager.PfxPassword = "******";

            ////Set Name(path) of the Root certificate file
            //proxyServer.CertificateManager.PfxFilePath = @"C:\NameFolder\rootCert.pfx";

            ////do you want Replace an existing Root certificate file(.pfx) if password is incorrect(RootCertificate=null)?  yes====>true
            //proxyServer.CertificateManager.OverwritePfxFile = true;

            ////save all fake certificates in folder "crts"(will be created in proxy dll directory)
            ////if create new Root certificate file(.pfx) ====> delete folder "crts"
            //proxyServer.CertificateManager.SaveFakeCertificates = true;

            proxyServer.ForwardToUpstreamGateway = true;

            ////if you need Load or Create Certificate now. ////// "true" if you need Enable===> Trust the RootCertificate used by this proxy server
            //proxyServer.CertificateManager.EnsureRootCertificate(true);

            ////or load directly certificate(As Administrator if need this)
            ////and At the same time chose path and password
            ////if password is incorrect and (overwriteRootCert=true)(RootCertificate=null) ====> replace an existing .pfx file
            ////note : load now (if existed)
            //proxyServer.CertificateManager.LoadRootCertificate(@"C:\NameFolder\rootCert.pfx", "PfxPassword");

            var explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000, true);

            proxyServer.AddEndPoint(explicitEndPoint);
            //proxyServer.UpStreamHttpProxy = new ExternalProxy
            //{
            //    HostName = "158.69.115.45",
            //    Port = 3128,
            //    UserName = "******",
            //    Password = "******",
            //};

            proxyServer.BeforeRequest  += ProxyServer_BeforeRequest;
            proxyServer.BeforeResponse += ProxyServer_BeforeResponse;
            proxyServer.AfterResponse  += ProxyServer_AfterResponse;
            explicitEndPoint.BeforeTunnelConnectRequest  += ProxyServer_BeforeTunnelConnectRequest;
            explicitEndPoint.BeforeTunnelConnectResponse += ProxyServer_BeforeTunnelConnectResponse;
            proxyServer.ClientConnectionCountChanged     += delegate
            {
                Dispatcher.Invoke(() => { ClientConnectionCount = proxyServer.ClientConnectionCount; });
            };
            proxyServer.ServerConnectionCountChanged += delegate
            {
                Dispatcher.Invoke(() => { ServerConnectionCount = proxyServer.ServerConnectionCount; });
            };
            proxyServer.Start();

            proxyServer.SetAsSystemProxy(explicitEndPoint, ProxyProtocolType.AllHttp);



            InitializeComponent();
        }