From f5330c97387d545f65199eded0ce3e23f9cb0ed9 Mon Sep 17 00:00:00 2001 From: ruri Date: Tue, 16 Apr 2019 23:54:56 +0200 Subject: [PATCH 1/4] Fixed bug on multiple data rules. --- RuriLib/Models/CData.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/RuriLib/Models/CData.cs b/RuriLib/Models/CData.cs index d50ee5a..af9b3a1 100644 --- a/RuriLib/Models/CData.cs +++ b/RuriLib/Models/CData.cs @@ -83,10 +83,13 @@ namespace RuriLib.Models valid = !CheckContains(slice, rule.RuleString); break; } + + if (!valid) return false; } catch { } } - return valid; + + return true; } /// From c85cb82dbe1ed53a701d071efd3b1ff71a8a844b Mon Sep 17 00:00:00 2001 From: openbullet <48930622+openbullet@users.noreply.github.com> Date: Wed, 17 Apr 2019 00:03:48 +0200 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 84b4665..88158dd 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Found a bug? [Create an issue!](https://help.github.com/en/articles/creating-an- # How to build 0. Make sure you have installed the .NET framework (dev) 4.6.1 (I will retarget to a more recent one soon). -1. **Clone this repository** and open it in Visual Studio. +1. **Clone this repository** and open the solution file with Visual Studio. 2. Switch to **Release** mode for a much cleaner output. 3. **Build** the solution (Visual Studio will fetch all the missing nuget packages). 4. You can find the executables inside the folders OpenBullet/bin/Release and OpenBulletCLI/bin/Release. From 64b1aac47e7cbc9fffc0ef3c48a84f61f5dc30cb Mon Sep 17 00:00:00 2001 From: ruri Date: Wed, 17 Apr 2019 10:50:54 +0200 Subject: [PATCH 3/4] Added a setting in RuriLib > Proxies to shuffle Proxies on Start. --- OpenBullet/Pages/Main/Runner/Runner.xaml.cs | 2 +- .../Main/Settings/RL/RLSettingsProxies.xaml | 1 + RuriLib/Models/ProxyPool.cs | 28 +++++++++++++++++-- RuriLib/Runner/RunnerViewModel.cs | 4 +-- .../ViewModels/RLSettings/SettingsProxies.cs | 4 +++ 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/OpenBullet/Pages/Main/Runner/Runner.xaml.cs b/OpenBullet/Pages/Main/Runner/Runner.xaml.cs index ddb9805..969d476 100644 --- a/OpenBullet/Pages/Main/Runner/Runner.xaml.cs +++ b/OpenBullet/Pages/Main/Runner/Runner.xaml.cs @@ -157,7 +157,7 @@ namespace OpenBullet else if (vm.Config.Settings.OnlySsl) toAdd = proxies.Where(x => x.Type == ProxyType.Http).ToList(); else toAdd = proxies; - vm.ProxyPool = new ProxyPool(toAdd); + vm.ProxyPool = new ProxyPool(toAdd, Globals.rlSettings.Proxies.ShuffleOnStart); } private void ProcessStatusChange(IRunnerMessaging sender) diff --git a/OpenBullet/Pages/Main/Settings/RL/RLSettingsProxies.xaml b/OpenBullet/Pages/Main/Settings/RL/RLSettingsProxies.xaml index ff1ff6f..7cbcacf 100644 --- a/OpenBullet/Pages/Main/Settings/RL/RLSettingsProxies.xaml +++ b/OpenBullet/Pages/Main/Settings/RL/RLSettingsProxies.xaml @@ -21,6 +21,7 @@ + public class ProxyPool { + private static Random rng = new Random(); + /// The full list of proxies in the pool. public List Proxies { get; } = new List(); @@ -35,9 +38,11 @@ namespace RuriLib.Models /// /// The collection of strings to parse the proxies from /// The type of the proxies - public ProxyPool(IEnumerable proxies, Extreme.Net.ProxyType type) + /// Whether to shuffle the proxy list + public ProxyPool(IEnumerable proxies, Extreme.Net.ProxyType type, bool shuffle) { Proxies = proxies.Select(p => new CProxy(p, type)).ToList(); + if (shuffle) Shuffle(Proxies); } /// @@ -46,7 +51,8 @@ namespace RuriLib.Models /// They will also be unbanned to make sure there are no leftovers from previous checks. /// /// The list of CProxy objects to be cloned and added to the list - public ProxyPool(List proxies) + /// Whether to shuffle the proxy list + public ProxyPool(List proxies, bool shuffle = false) { // We clone the list, since we don't want to target to the same objects that are in the Proxy Manager // If we don't do this, a ban on a runner instance would cause a ban on all the other instances as well! @@ -54,6 +60,9 @@ namespace RuriLib.Models // Now that the list is cloned, we make sure that no proxy is already banned UnbanAll(); + + // Shuffle it if necessary + if (shuffle) Shuffle(Proxies); } /// @@ -126,5 +135,18 @@ namespace RuriLib.Models Locked = false; return proxy; } + + private static void Shuffle(IList list) + { + int n = list.Count; + while (n > 1) + { + n--; + int k = rng.Next(n + 1); + T value = list[k]; + list[k] = list[n]; + list[n] = value; + } + } } } diff --git a/RuriLib/Runner/RunnerViewModel.cs b/RuriLib/Runner/RunnerViewModel.cs index 21db2ff..0c6dd9e 100644 --- a/RuriLib/Runner/RunnerViewModel.cs +++ b/RuriLib/Runner/RunnerViewModel.cs @@ -982,7 +982,7 @@ namespace RuriLib.Runner ProxyPool = new ProxyPool( GetProxiesFromAPI(Settings.Proxies.ReloadPath, Settings.Proxies.ReloadType, - Settings.Proxies.ParseWithIPRegex)); + Settings.Proxies.ParseWithIPRegex), Settings.Proxies.ShuffleOnStart); } catch (Exception ex) { RaiseMessageArrived(LogLevel.Error, $"Could not contact the reload API - {ex.Message}", true); } break; @@ -993,7 +993,7 @@ namespace RuriLib.Runner ProxyPool = new ProxyPool( GetProxiesFromFile(Settings.Proxies.ReloadPath, Settings.Proxies.ReloadType, - Settings.Proxies.ParseWithIPRegex)); + Settings.Proxies.ParseWithIPRegex), Settings.Proxies.ShuffleOnStart); } catch (Exception ex) { RaiseMessageArrived(LogLevel.Error, $"Could not read the proxies from file - {ex.Message}", true); } break; diff --git a/RuriLib/ViewModels/RLSettings/SettingsProxies.cs b/RuriLib/ViewModels/RLSettings/SettingsProxies.cs index 3a65990..a39deb0 100644 --- a/RuriLib/ViewModels/RLSettings/SettingsProxies.cs +++ b/RuriLib/ViewModels/RLSettings/SettingsProxies.cs @@ -32,6 +32,10 @@ namespace RuriLib.ViewModels private bool banAfterGoodStatus = false; /// Whether to never ban the proxy after a SUCCESS, CUSTOM or NONE status (not FAIL or RETRY). public bool BanAfterGoodStatus { get { return banAfterGoodStatus; } set { banAfterGoodStatus = value; OnPropertyChanged(); } } + + private bool shuffleOnStart = false; + /// Whether proxy lists should be shuffled before being assigned to the Runner. + public bool ShuffleOnStart { get { return shuffleOnStart; } set { shuffleOnStart = value; OnPropertyChanged(); } } #endregion #region Reload From 476333c1d3a786a8b2e01927333a905e650dd0a4 Mon Sep 17 00:00:00 2001 From: ruri Date: Wed, 17 Apr 2019 16:27:59 +0200 Subject: [PATCH 4/4] Fixed 2captcha to work with CapMonster and XEvil (switched from json to plaintext response). --- RuriLib/CaptchaServices/TwoCaptcha.cs | 38 +++++++++++---------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/RuriLib/CaptchaServices/TwoCaptcha.cs b/RuriLib/CaptchaServices/TwoCaptcha.cs index 10c10ba..47788a1 100644 --- a/RuriLib/CaptchaServices/TwoCaptcha.cs +++ b/RuriLib/CaptchaServices/TwoCaptcha.cs @@ -26,10 +26,8 @@ namespace RuriLib.CaptchaServices using (CWebClient client = new CWebClient()) { if (Timeout > 0) client.Timeout = Timeout; - var response = client.DownloadString($"http://2captcha.com/res.php?key={ApiKey}&action=getbalance&json=1"); - GenericResponse gbr = JsonConvert.DeserializeObject(response); - if (gbr.status == 0) throw new Exception(gbr.request); - return double.Parse(gbr.request, CultureInfo.InvariantCulture); + var response = client.DownloadString($"http://2captcha.com/res.php?key={ApiKey}&action=getbalance"); + return double.Parse(response, CultureInfo.InvariantCulture); } } @@ -40,10 +38,9 @@ namespace RuriLib.CaptchaServices using (CWebClient client = new CWebClient()) { if (Timeout > 0) client.Timeout = Timeout; - var response = client.DownloadString($"http://2captcha.com/in.php?key={ApiKey}&method=userrecaptcha&googlekey={siteKey}&pageurl={siteUrl}&json=1"); - GenericResponse ctr = JsonConvert.DeserializeObject(response); - if (ctr.status == 0) throw new Exception(ctr.request); - TaskId = ctr.request; + var response = client.DownloadString($"http://2captcha.com/in.php?key={ApiKey}&method=userrecaptcha&googlekey={siteKey}&pageurl={siteUrl}"); + if (!response.StartsWith("OK")) throw new Exception(response); + TaskId = response.Split('|')[1]; Status = CaptchaStatus.Processing; // Check if task has been completed @@ -51,12 +48,11 @@ namespace RuriLib.CaptchaServices while (Status == CaptchaStatus.Processing && (DateTime.Now - start).TotalSeconds < Timeout) { Thread.Sleep(5000); - response = client.DownloadString($"http://2captcha.com/res.php?key={ApiKey}&action=get&id={TaskId}&json=1"); - GenericResponse gtrr = JsonConvert.DeserializeObject(response); - if (gtrr.request.Contains("NOT_READY")) continue; - if (gtrr.status == 0) throw new Exception(gtrr.request); + response = client.DownloadString($"http://2captcha.com/res.php?key={ApiKey}&action=get&id={TaskId}"); + if (response.Contains("NOT_READY")) continue; + if (response.Contains("ERROR")) throw new Exception(response); Status = CaptchaStatus.Completed; - return gtrr.request; + return response.Split('|')[1]; } throw new TimeoutException(); } @@ -71,10 +67,9 @@ namespace RuriLib.CaptchaServices if (Timeout > 0) client.Timeout = Timeout; client.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded"); var response = client.UploadString("http://2captcha.com/in.php", - $"key={ApiKey}&method=base64®sense=1&body={GetBase64(bitmap, ImageFormat.Bmp)}&json=1"); - GenericResponse ctr = JsonConvert.DeserializeObject(response); - if (ctr.status == 0) throw new Exception(ctr.request); - TaskId = ctr.request; + $"key={ApiKey}&method=base64®sense=1&body={GetBase64(bitmap, ImageFormat.Bmp)}"); + if (!response.StartsWith("OK")) throw new Exception(response); + TaskId = response.Split('|')[1]; Status = CaptchaStatus.Processing; // Check if task has been completed @@ -82,12 +77,11 @@ namespace RuriLib.CaptchaServices while (Status == CaptchaStatus.Processing && (DateTime.Now - start).TotalSeconds < Timeout) { Thread.Sleep(5000); - response = client.DownloadString($"http://2captcha.com/res.php?key={ApiKey}&action=get&id={TaskId}&json=1"); - GenericResponse gtrr = JsonConvert.DeserializeObject(response); - if (gtrr.request.Contains("NOT_READY")) continue; - if (gtrr.status == 0) throw new Exception(gtrr.request); + response = client.DownloadString($"http://2captcha.com/res.php?key={ApiKey}&action=get&id={TaskId}"); + if (response.Contains("NOT_READY")) continue; + if (response.Contains("ERROR")) throw new Exception(response); Status = CaptchaStatus.Completed; - return gtrr.request; + return response.Split('|')[1]; } throw new TimeoutException(); }