Пример #1
0
        public async Task CheckProxyAsync(CProxy proxy, SemaphoreSlim semaphore, CancellationToken token)
        {
            await semaphore.WaitAsync(token).ConfigureAwait(false);

            try
            {
                token.ThrowIfCancellationRequested();
                if (Status != WorkerStatus.Running)
                {
                    throw new OperationCanceledException();
                }

                // We do it like this, otherwise if we make the requests async the ping measurement won't work
                await Task.Run(new Action(() =>
                {
                    CheckCountry(proxy);
                    CheckProxy(proxy);
                    App.Current.Dispatcher.Invoke(new Action(() => vm.UpdateProperties()));
                }));
            }
            catch (OperationCanceledException)
            {
                Globals.LogInfo(Components.ProxyManager, $"{proxy} - THROWING");
                throw;
            }
            finally
            {
                semaphore.Release();
            }
        }
Пример #2
0
        private void CheckCountry(CProxy proxy)
        {
            try
            {
                using (var request = new HttpRequest())
                {
                    request.ConnectTimeout = (int)vm.Timeout;
                    var response = request.Get("http://ip-api.com/csv/" + proxy.Host);
                    var csv      = response.ToString();
                    var split    = csv.Split(',');

                    var country = "Unknown";

                    if (split[0] == "success")
                    {
                        country = split[1];
                    }

                    proxy.Country = country.Replace("\"", "");

                    using (var db = new LiteDatabase(Globals.dataBaseFile))
                    {
                        db.GetCollection <CProxy>("proxies").Update(proxy);
                    }

                    Globals.LogInfo(Components.ProxyManager, "Checked country for proxy '" + proxy.Proxy + "' with result '" + proxy.Country + "'");
                }
            }
            catch (Exception ex) { Globals.LogError(Components.ProxyManager, "Failted to check country for proxy '" + proxy.Proxy + $"' - {ex.Message}"); }
        }
Пример #3
0
        public void AddProxies(List <string> lines, ProxyType defaultType = ProxyType.Http, string defaultUsername = "", string defaultPassword = "")
        {
            Globals.LogInfo(Components.ProxyManager, $"Adding {lines.Count} {defaultType} proxies to the database");

            // Check if they're valid
            var proxies = new List <CProxy>();

            foreach (var p in lines.Where(p => !string.IsNullOrEmpty(p)).Distinct().ToList())
            {
                try
                {
                    CProxy proxy = new CProxy().Parse(p, defaultType, defaultUsername, defaultPassword);
                    if (!proxy.IsNumeric || proxy.IsValidNumeric)
                    {
                        vm.ProxyList.Add(proxy);
                        proxies.Add(proxy);
                    }
                }
                catch { }
            }

            using (var db = new LiteDatabase(Globals.dataBaseFile))
            {
                db.GetCollection <CProxy>("proxies").InsertBulk(proxies);
            }

            // Refresh
            vm.UpdateProperties();
        }
Пример #4
0
        private void CheckProxy(CProxy proxy)
        {
            var before = DateTime.Now;

            try
            {
                using (var request = new HttpRequest())
                {
                    request.Proxy          = proxy.GetClient();
                    request.ConnectTimeout = (int)vm.Timeout;
                    var response = request.Get(vm.TestURL);
                    var source   = response.ToString();

                    App.Current.Dispatcher.Invoke(new Action(() => proxy.Ping = (DateTime.Now - before).Milliseconds));

                    App.Current.Dispatcher.Invoke(new Action(() => proxy.Working = source.Contains(vm.SuccessKey) ? ProxyWorking.YES : ProxyWorking.NO));

                    Globals.LogInfo(Components.ProxyManager, "Proxy '" + proxy.Proxy + $"' responded in {proxy.Ping} ms");
                }
            }
            catch (Exception ex)
            {
                Globals.LogInfo(Components.ProxyManager, "Proxy '" + proxy.Proxy + $"' failed to respond - {ex.Message}");
                App.Current.Dispatcher.Invoke(new Action(() => proxy.Working = ProxyWorking.NO));
            }

            using (var db = new LiteDatabase(Globals.dataBaseFile))
            {
                db.GetCollection <CProxy>("proxies").Update(proxy);
            }
        }
        private void btnRefresh_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Bitmap bmp;
                CProxy proxy = null;
                if (!imageFromFile)
                {
                    if (chbProxy.IsChecked.GetValueOrDefault() && chbProxy.IsEnabled)
                    {
                        proxy = blockOcr.CreateProxy(proxyTextbox.Text, proxyTypeCombobox.SelectedItem.ToString().ToEnum(ProxyType.Http));
                    }
                    bmp = blockOcr.GetOcrImage(false, proxy);
                }
                else
                {
                    bmp = (Bitmap)System.Drawing.Image.FromFile(path);
                }
                OrigImage.Image = bmp;

                //apply filter
                var proc = blockOcr.ApplyFilters(bmp.Clone() as Bitmap);
                ProcImage.Image = proc;
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "NOTICE",
                                                     System.Windows.Forms.MessageBoxButtons.OK,
                                                     System.Windows.Forms.MessageBoxIcon.Error);
            }
        }
Пример #6
0
        /// <summary>
        /// Creates a BotData object given some parameters.
        /// </summary>
        /// <param name="globalSettings">The global RuriLib settings</param>
        /// <param name="configSettings">The settings for the current Config</param>
        /// <param name="data">The wrapped data line to check</param>
        /// <param name="proxy">The proxy to use (set to null if none)</param>
        /// <param name="useProxies">Whether to use the proxy for requests</param>
        /// <param name="botNumber">The number of the bot that is creating this object</param>
        /// <param name="isDebug">Whether this object is created from a Debugger or from a Runner</param>
        public BotData(RLSettingsViewModel globalSettings, ConfigSettings configSettings, CData data, CProxy proxy, bool useProxies, int botNumber = 0, bool isDebug = true)
        {
            Data           = data;
            Proxy          = proxy;
            UseProxies     = useProxies;
            Status         = BotStatus.NONE;
            BotNumber      = BotNumber;
            GlobalSettings = globalSettings;
            ConfigSettings = configSettings;
            Balance        = 0;
            Screenshots    = new List <string>();
            Variables      = new VariableList();

            // Populate the Variables list with hidden variables
            Address         = "";
            ResponseCode    = "0";
            ResponseSource  = "";
            Cookies         = new Dictionary <string, string>();
            ResponseHeaders = new Dictionary <string, string>();
            try { foreach (var v in Data.GetVariables())
                  {
                      Variables.Set(v);
                  }
            } catch { }

            GlobalVariables = new VariableList();
            GlobalCookies   = new CookieDictionary();
            LogBuffer       = new List <LogEntry>();
            Driver          = null;
            BrowserOpen     = false;
            IsDebug         = isDebug;
            BotNumber       = botNumber;
        }
Пример #7
0
        // TODO: Refactor this function, it shouldn't belong in a view!
        public void AddProxies(IEnumerable <string> raw, ProxyType defaultType = ProxyType.Http, string defaultUsername = "", string defaultPassword = "")
        {
            SB.Logger.LogInfo(Components.ProxyManager, $"Adding {raw.Count()} {defaultType} proxies to the database");

            // Check if they're valid
            var proxies = new List <CProxy>();

            foreach (var p in raw.Where(p => !string.IsNullOrEmpty(p)).Distinct().ToList())
            {
                try
                {
                    CProxy proxy = new CProxy().Parse(p, defaultType, defaultUsername, defaultPassword);
                    if (!proxy.IsNumeric || proxy.IsValidNumeric)
                    {
                        proxies.Add(proxy);
                    }
                }
                catch { }
            }

            vm.AddRange(proxies);

            // Refresh
            vm.UpdateProperties();
        }
Пример #8
0
 /// <summary>
 /// Initializes a proxy check result.
 /// </summary>
 /// <param name="proxy">The proxy that was tested</param>
 /// <param name="working">Whether the proxy works</param>
 /// <param name="ping">The ping in milliseconds</param>
 /// <param name="country">The approximate location of the proxy server (if it was tested)</param>
 public ProxyResult(CProxy proxy, bool working, int ping, string country = "Unknown")
 {
     this.proxy   = proxy;
     this.working = working;
     this.ping    = ping;
     this.country = country;
 }
Пример #9
0
        public void AddProxies(string fileName, ProxyType type, List <string> lines)
        {
            List <string> fromFile = new List <string>();
            List <string> fromBox  = new List <string>();

            // Load proxies from file
            if (fileName != "")
            {
                Globals.LogInfo(Components.ProxyManager, $"Trying to load from file {fileName}");

                fromFile.AddRange(File.ReadAllLines(fileName).ToList());
            }
            else
            {
                Globals.LogInfo(Components.ProxyManager, "No file specified, skipping the import from file");
            }

            // Load proxies from textbox lines
            fromBox.AddRange(lines);

            Globals.LogInfo(Components.ProxyManager, $"Adding {fromFile.Count + fromBox.Count} proxies to the database");

            // Check if they're valid
            using (var db = new LiteDatabase(Globals.dataBaseFile))
            {
                foreach (var p in fromFile.Where(p => !string.IsNullOrEmpty(p)).Distinct().ToList())
                {
                    try
                    {
                        CProxy proxy = new CProxy(p, type);
                        if (!proxy.IsNumeric || proxy.IsValidNumeric)
                        {
                            vm.ProxyList.Add(proxy);
                            db.GetCollection <CProxy>("proxies").Insert(proxy);
                        }
                    }
                    catch { }
                }

                foreach (var p in fromBox.Where(p => !string.IsNullOrEmpty(p)).Distinct().ToList())
                {
                    try
                    {
                        CProxy proxy = new CProxy();
                        proxy.Parse(p, type);
                        if (!proxy.IsNumeric || proxy.IsValidNumeric)
                        {
                            vm.ProxyList.Add(proxy);
                            db.GetCollection <CProxy>("proxies").Insert(proxy);
                        }
                    }
                    catch { }
                }
            }

            // Refresh
            vm.UpdateProperties();
        }
        public IEnumerator Proxy_Test()
        {
            CManagerFirebase_Test pTester = CreateTesterObject(nameof(Proxy_Test));

            yield return(pTester.StartCoroutine(WaitForInit(pTester)));

            CManagerFirebase pManagerFirebase = CManagerFirebase.instance;

            int      iRandomNumber = UnityEngine.Random.Range(0, int.MaxValue);
            string   strDBKey      = "Test User ID " + iRandomNumber.ToString();
            TestData pTestData     = new TestData(strDBKey, "Test User Name" + iRandomNumber.ToString(), iRandomNumber);

            // 프록시를 통해 데이터를 삽입한다. DB에 데이터가 있으면 DB에있는 데이터가 들어온다.
            CProxy <TestData> pProxyData = new CProxy <TestData>(strDBKey, pTestData, 0.1f, OnFinish_Proxy);

            // 프록시를 통해 순간적으로 대량의 수정 요청을 한다.
            int iGoldResult = pTestData.iGold;

            for (int i = 0; i < 1000; i++)
            {
                int iGoldChangeAmount = UnityEngine.Random.Range(-100, 100);
                pProxyData.pData_RequireUpdate_Directly.iGold += iGoldChangeAmount;
                iGoldResult += iGoldChangeAmount;
            }


            // DB 갱신까지 잠시 기다린다.
            float fElpaseTime = 0f;

            while (pProxyData.p_bIsWaitServer && fElpaseTime < 5f)
            {
                fElpaseTime += Time.deltaTime;
                yield return(null);
            }

            if (fElpaseTime >= 5f)
            {
                Debug.LogError("시간 초과" + fElpaseTime);
                yield break;
            }

            _pData = null;
            Assert.IsNull(_pData);

            // DB로부터 데이터를 얻어온 데이터와 로컬의 프록시와 일치하는지 확인한다.
            yield return(pTester.StartCoroutine(pManagerFirebase.DoGetData_Single_Coroutine <TestData>(pTestData.IFirebaseData_strDBKey, OnFinishGetData_Single)));

            Assert.AreEqual(pProxyData.pData.iGold, _pData.iGold, iGoldResult);

            // 테스트를 끝낸 뒤 데이터를 삭제한다.
            yield return(pTester.StartCoroutine(pManagerFirebase.DoRemoveData_Coroutine <TestData>(pTestData, null)));

            yield break;
        }
Пример #11
0
        /// <summary>
        /// Sets a proxy to be used during the request.
        /// </summary>
        /// <param name="proxy">The proxy</param>
        /// <returns>The request itself</returns>
        public Request SetProxy(CProxy proxy)
        {
            request.Proxy = proxy.GetClient();

            request.Proxy.ReadWriteTimeout = timeout;
            request.Proxy.ConnectTimeout   = timeout;
            request.Proxy.Username         = proxy.Username;
            request.Proxy.Password         = proxy.Password;

            return(this);
        }
Пример #12
0
        public async Task <IActionResult> GetServerTime()
        {
            return(await CProxy.UsingAsync(() =>
            {
                return Ok(new
                {
                    success = true,
                    message = "",

                    result = CUnixTime.LocalNow
                });
            }));
        }
Пример #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            IProxy proxy = new CProxy();

            ciudadesbuscadas = proxy.paises();
            foreach (RootObject a in ciudadesbuscadas)
            {
                _service.AddCapitales(a);
            }
            dataGridView1.DataSource = new BindingSource(ciudadesbuscadas, null);
            dataGridView1.DataSource = typeof(List <RootObject>);
            dataGridView1.DataSource = ciudadesbuscadas;
            dataGridView1.Update();
            dataGridView1.Refresh();
        }
Пример #14
0
        public async Task <IActionResult> GetAnalysis()
        {
            return(await CProxy.Using(() =>
            {
                var _result = __db_context.TbLionAnalysis
                              .OrderByDescending(w => w.SequenceNo)
                              .ToList();

                return new OkObjectResult(new
                {
                    success = true,
                    message = "",

                    result = _result
                });
            }));
        }
Пример #15
0
        public async Task <IActionResult> GetWinners()
        {
            return(await CProxy.UsingAsync(() =>
            {
                var _result = __db_context.tb_lion_winner
                              .OrderByDescending(w => w.SequenceNo)
                              .ToList();

                return Ok(new
                {
                    success = true,
                    message = "",

                    result = _result
                });
            }));
        }
Пример #16
0
        public async Task <IActionResult> GetWinnersWithPage(int pageIndex, int pageRows)
        {
            return(await CProxy.Using(() =>
            {
                var _result = __db_context.TbLionWinner
                              .OrderByDescending(w => w.SequenceNo)
                              .Skip((pageIndex - 1) * pageRows).Take(pageRows)
                              .ToList();

                return new OkObjectResult(new
                {
                    success = true,
                    message = "",

                    result = _result
                });
            }));
        }
Пример #17
0
        public async Task <IActionResult> GetVersion()
        {
            return(await CProxy.Using(() =>
            {
                if (__version == null)
                {
                    __version = new ProductInfo("LottoLion-WebApi", "v1.0.0", "webapi service for LottoLion", ProductType.service);
                }

                return new OkObjectResult(new
                {
                    success = true,
                    message = "",

                    result = __version
                });
            }));
        }
Пример #18
0
        public async Task <IActionResult> GetVersion()
        {
            return(await CProxy.UsingAsync(() =>
            {
                if (__version == null)
                {
                    __version = new ProductInfo("Lion.WebApi", "v3.1.0", "WebApi Service for Lotto-Lion", ProductType.service);
                }

                return Ok(new
                {
                    success = true,
                    message = "",

                    result = __version
                });
            }));
        }
Пример #19
0
        public async Task <IActionResult> GetGuestToken()
        {
            return(await CProxy.UsingAsync(async() =>
            {
                return new OkObjectResult(new
                {
                    success = true,
                    message = "",

                    result = await __usermgr.GetEncodedJwt(
                        new ApplicationUser()
                    {
                        login_id = "guest",
                        mail_address = ""
                    },
                        new Claim("UserType", "Guest")
                        )
                });
            }));
        }
Пример #20
0
        /// <summary>
        /// Downloads a remote file.
        /// </summary>
        /// <param name="fileName">The destination file on disk</param>
        /// <param name="url">The URL of the remote file</param>
        /// <param name="useProxies">Whether to use proxies for the request</param>
        /// <param name="proxy">The proxy, if needed</param>
        /// <param name="cookies">The cookies to use in the request</param>
        /// <param name="newCookies">The new cookie dictionary containing the new cookies too</param>
        /// <param name="timeout">The request timeout in milliseconds</param>
        /// <param name="userAgent">The user agent to use</param>
        public static void RemoteFile(
            string fileName, string url, bool useProxies, CProxy proxy, Dictionary <string, string> cookies, out Dictionary <string, string> newCookies, int timeout, string userAgent = "")
        {
            HttpRequest request = new HttpRequest();

            if (userAgent != string.Empty)
            {
                request.UserAgent = userAgent;
            }
            request.Cookies = new CookieDictionary();
            foreach (var cookie in cookies)
            {
                request.Cookies.Add(cookie.Key, cookie.Value);
            }

            // Set proxy
            if (useProxies)
            {
                request.Proxy = proxy.GetClient();
                request.Proxy.ReadWriteTimeout = timeout;
                request.Proxy.ConnectTimeout   = timeout;
                request.Proxy.Username         = proxy.Username;
                request.Proxy.Password         = proxy.Password;
            }

            HttpResponse response = request.Get(url);

            using (Stream inputStream = response.ToMemoryStream())
                using (Stream outputStream = File.OpenWrite(fileName))
                {
                    byte[] buffer = new byte[4096];
                    int    bytesRead;
                    do
                    {
                        bytesRead = inputStream.Read(buffer, 0, buffer.Length);
                        outputStream.Write(buffer, 0, bytesRead);
                    } while (bytesRead != 0);
                }

            newCookies = response.Cookies;
        }
 private void btnLoad_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(OcrUrl.Text))
         {
             return;
         }
         CProxy proxy = null;
         if (chbProxy.IsChecked.GetValueOrDefault() && chbProxy.IsEnabled)
         {
             proxy = blockOcr.CreateProxy(proxyTextbox.Text, proxyTypeCombobox.SelectedItem.ToString().ToEnum(ProxyType.Http));
         }
         var bmp = blockOcr.GetOcrImage(false, proxy);
         OrigImage.Image = bmp;
         ProcImage.Image = bmp.Clone() as Bitmap;
         imageFromFile   = false;
     }
     catch (Exception ex)
     {
         SB.Logger.LogError(Components.OcrTesting, ex.Message, true);
     }
 }
Пример #22
0
        /// <summary>
        /// Creates a BotData object given some parameters.
        /// </summary>
        /// <param name="globalSettings">The global RuriLib settings</param>
        /// <param name="configSettings">The settings for the current Config</param>
        /// <param name="data">The wrapped data line to check</param>
        /// <param name="proxy">The proxy to use (set to null if none)</param>
        /// <param name="useProxies">Whether to use the proxy for requests</param>
        /// <param name="random">A reference to the global random generator</param>
        /// <param name="botNumber">The number of the bot that is creating this object</param>
        /// <param name="id">Data id Runner</param>
        /// <param name="isDebug">Whether this object is created from a Debugger or from a Runner</param>
        public BotData(RLSettingsViewModel globalSettings, ConfigSettings configSettings, CData data, CProxy proxy, bool useProxies, Random random, int botNumber = 0, bool isDebug = true)
        {
            Data           = data;
            Proxy          = proxy;
            UseProxies     = useProxies;
            this.random    = new Random(random.Next(0, int.MaxValue)); // Create a new local RNG seeded with a random seed from the global RNG
            Status         = BotStatus.NONE;
            BotNumber      = BotNumber;
            GlobalSettings = globalSettings;
            ConfigSettings = configSettings;
            Balance        = 0;
            Screenshots    = new List <string>();
            Variables      = new VariableList();

            // Populate the Variables list with hidden variables
            Address         = "";
            ResponseCode    = "0";
            ResponseSource  = "";
            ResponseStream  = null;
            Cookies         = new Dictionary <string, string>();
            ResponseHeaders = new Dictionary <string, string>();
            try { foreach (var v in Data.GetVariables(ConfigSettings.EncodeData))
                  {
                      Variables.Set(v);
                  }
            } catch { }

            GlobalVariables = new VariableList();
            GlobalCookies   = new CookieDictionary();
            LogBuffer       = new List <LogEntry>();
            Driver          = null;
            BrowserOpen     = false;
            IsDebug         = isDebug;
            BotNumber       = botNumber;

            CustomObjects = new Dictionary <string, object>();
        }
        private void debuggerCheck(object sender, DoWorkEventArgs e)
        {
            // Dispose of previous browser (if any)
            if (vm.BotData != null)
            {
                if (vm.BotData.BrowserOpen)
                {
                    OB.Logger.LogInfo(Components.Stacker, "Quitting the previously opened browser");
                    vm.BotData.Driver.Quit();
                    OB.Logger.LogInfo(Components.Stacker, "Quitted correctly");
                }
            }

            // Convert Observables
            OB.Logger.LogInfo(Components.Stacker, "Converting Observables");
            vm.ConvertKeychains();

            // Initialize Request Data
            OB.Logger.LogInfo(Components.Stacker, "Initializing the request data");
            CProxy proxy = null;

            if (vm.TestProxy.StartsWith("(")) // Parse in advanced mode
            {
                try { proxy = (new CProxy()).Parse(vm.TestProxy); }
                catch { OB.Logger.LogError(Components.Stacker, "Invalid Proxy Syntax", true); }
            }
            else // Parse in standard mode
            {
                proxy = new CProxy(vm.TestProxy, vm.ProxyType);
            }

            // Initialize BotData and Reset LS
            var cData = new CData(vm.TestData, OB.Settings.Environment.GetWordlistType(vm.TestDataType));

            vm.BotData = new BotData(OB.Settings.RLSettings, vm.Config.Config.Settings, cData, proxy, vm.UseProxy, new Random());
            vm.LS.Reset();

            // Ask for user input
            foreach (var input in vm.BotData.ConfigSettings.CustomInputs)
            {
                OB.Logger.LogInfo(Components.Stacker, $"Asking for user input: {input.Description}");
                App.Current.Dispatcher.Invoke(new Action(() =>
                {
                    (new MainDialog(new DialogCustomInput(vm, input.VariableName, input.Description), "Custom Input")).ShowDialog();
                }));
            }

            // Set start block
            OB.Logger.LogInfo(Components.Stacker, "Setting the first block as the current block");

            // Print start line
            var proxyEnabledText = vm.UseProxy ? "ENABLED" : "DISABLED";

            vm.BotData.LogBuffer.Add(new LogEntry($"===== DEBUGGER STARTED FOR CONFIG {vm.Config.Name} WITH DATA {vm.TestData} AND PROXY {vm.TestProxy} ({vm.ProxyType}) {proxyEnabledText} ====={Environment.NewLine}", Colors.White));

            timer = new Stopwatch();
            timer.Start();

            // Open browser if Always Open
            if (vm.Config.Config.Settings.AlwaysOpen)
            {
                OB.Logger.LogInfo(Components.Stacker, "Opening the Browser");
                SBlockBrowserAction.OpenBrowser(vm.BotData);
            }

            // Step-by-step
            if (vm.SBS)
            {
                vm.SBSClear = true; // Good to go for the first round
                do
                {
                    Thread.Sleep(100);

                    if (debugger.CancellationPending)
                    {
                        OB.Logger.LogInfo(Components.Stacker, "Found cancellation pending, aborting debugger");
                        return;
                    }

                    if (vm.SBSClear)
                    {
                        vm.SBSEnabled = false;
                        Process();
                        OB.Logger.LogInfo(Components.Stacker, $"Block processed in SBS mode, can proceed: {vm.LS.CanProceed}");
                        vm.SBSEnabled = true;
                        vm.SBSClear   = false;
                    }
                }while (vm.LS.CanProceed);
            }

            // Normal
            else
            {
                do
                {
                    if (debugger.CancellationPending)
                    {
                        OB.Logger.LogInfo(Components.Stacker, "Found cancellation pending, aborting debugger");
                        return;
                    }

                    Process();
                }while (vm.LS.CanProceed);
            }

            // Quit Browser if Always Quit
            if (vm.Config.Config.Settings.AlwaysQuit || (vm.Config.Config.Settings.QuitOnBanRetry && (vm.BotData.Status == BotStatus.BAN || vm.BotData.Status == BotStatus.RETRY)))
            {
                try {
                    vm.BotData.Driver.Quit();
                    vm.BotData.BrowserOpen = false;
                    OB.Logger.LogInfo(Components.Stacker, "Successfully quit the browser");
                }
                catch (Exception ex) { OB.Logger.LogError(Components.Stacker, $"Cannot quit the browser - {ex.Message}"); }
            }
        }
Пример #24
0
 private void buttonRemove_Click(object sender, EventArgs e)
 {
     if (textBoxRemove.Text == "")
     {
         status.AppendText("Enter a proxy to remove\r\n");
     }
     else
     {
         CProxy proxy = new CProxy();
         string text = textBoxRemove.Text;
         char[] separator = new char[] { ':' };
         string[] strArray = text.Split((string[]) null, StringSplitOptions.RemoveEmptyEntries)[0].Split(separator);
         if (strArray.Length != 2)
         {
             status.AppendText("Bad proxy format\r\n");
         }
         else
         {
             proxy.ip = strArray[0];
             int num3 = int.Parse(strArray[1]);
             proxy.port = num3;
             bool flag = false;
             List<CProxy>[] proxytable = this.proxytable;
             int index = 0;
             if (0 < proxytable.Length)
             {
                 do
                 {
                     List<CProxy> list = proxytable[index];
                     int num = 0;
                     if (0 < list.Count)
                     {
                         string ip = proxy.ip;
                         do
                         {
                             if ((list[num].ip == ip) && (list[num].port == num3))
                             {
                                 list.RemoveAt(num);
                                 labelProxyCount.Text = proxies_count().ToString();
                                 flag = true;
                                 break;
                             }
                             num++;
                         }
                         while (num < list.Count);
                     }
                     index++;
                 }
                 while (index < proxytable.Length);
                 if (flag)
                 {
                     status.AppendText(text + " has been removed\r\n");
                     return;
                 }
             }
             status.AppendText("No such proxy\r\n");
         }
     }
 }
Пример #25
0
 private void buttonLoadProxies_Click(object sender, EventArgs e)
 {
     if (openFileDialogProxy.ShowDialog() != DialogResult.Cancel)
     {
         string fileName = openFileDialogProxy.FileName;
         status.AppendText("Loading " + Path.GetFileName(fileName) + "...");
         int num = 0;
         try
         {
             string str;
             StreamReader reader = new StreamReader(fileName);
         Label_004F:
             str = reader.ReadLine();
             if (str != null)
             {
                 try
                 {
                     char[] separator = new char[] { ':' };
                     string[] strArray = str.Split((string[]) null, StringSplitOptions.RemoveEmptyEntries)[0].Split(separator);
                     CProxy item = new CProxy();
                     if (strArray.Length == 2)
                     {
                         item.ip = strArray[0];
                         item.port = int.Parse(strArray[1]);
                         bool flag = false;
                         List<CProxy>.Enumerator enumerator = triedproxies.GetEnumerator();
                         while (enumerator.MoveNext())
                         {
                             CProxy current = enumerator.Current;
                             if ((item.ip == current.ip) && (item.port == current.port))
                             {
                                 flag = true;
                             }
                         }
                         if (!flag)
                         {
                             triedproxies.Add(item);
                             BackgroundWorker worker = new BackgroundWorker {
                                 WorkerReportsProgress = true
                             };
                             worker.DoWork += testProxy_DoWork;
                             worker.ProgressChanged += testProxy_ProgressChanged;
                             worker.RunWorkerAsync(item);
                             num++;
                         }
                     }
                 }
                 catch (Exception)
                 {
                 }
                 goto Label_004F;
             }
             reader.Close();
         }
         catch (Exception)
         {
         }
         status.AppendText(num + " new proxies found\r\n");
     }
 }