using RuriLib.Models; using RuriLib.ViewModels; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; namespace RuriLib { /// /// Contains all the settings of a Config. /// public class ConfigSettings : ViewModelBase { #region General private string name = ""; /// The name of the Config. public string Name { get { return name; } set { name = value; OnPropertyChanged(); } } private int suggestedBots = 1; /// The suggested amount of Bots that should be used with the config. public int SuggestedBots { get { return suggestedBots; } set { suggestedBots = value; OnPropertyChanged(); } } private int maxCPM = 0; /// The maximum CPM around which the Master Worker will stop starting bots and wait for the CPM to decrease below the threshold. public int MaxCPM { get { return maxCPM; } set { maxCPM = value; OnPropertyChanged(); } } private DateTime lastModified = DateTime.Now; /// When the Config was last modified. public DateTime LastModified { get { return lastModified; } set { lastModified = value; OnPropertyChanged(); } } private string additionalInfo = ""; /// Additional information on the Config usage. public string AdditionalInfo { get { return additionalInfo; } set { additionalInfo = value; OnPropertyChanged(); } } private string author = ""; /// The name of the Author of the Config. public string Author { get { return author; } set { author = value; OnPropertyChanged(); } } private string version = "1.1.3"; /// The version of RuriLib the Config was made with. public string Version { get { return version; } set { version = value; OnPropertyChanged(); } } #endregion #region Requests private bool ignoreResponseErrors = false; /// Whether to proceed if an HTTP request fails instead of giving the ERROR status. public bool IgnoreResponseErrors { get { return ignoreResponseErrors; } set { ignoreResponseErrors = value; OnPropertyChanged(); } } private int _maxRedirects = 8; /// The maximum amount of times we can be redirected to different URLs for a single request. public int MaxRedirects { get { return _maxRedirects; } set { _maxRedirects = value; OnPropertyChanged(); } } #endregion #region Proxy private bool needsProxies = false; /// Whether the Config needs proxies to work (the Runner can override this). public bool NeedsProxies { get { return needsProxies; } set { needsProxies = value; OnPropertyChanged(); } } private bool onlySocks = false; /// Whether only SOCKS proxies should be used. public bool OnlySocks { get { return onlySocks; } set { onlySocks = value; OnPropertyChanged(); } } private bool onlySsl = false; /// Whether only SSL proxies should be used. public bool OnlySsl { get { return onlySsl; } set { onlySsl = value; OnPropertyChanged(); } } private int maxProxyUses = 0; /// The maximum amount of times a proxy can be used before being banned by the Runner (0 for infinite). public int MaxProxyUses { get { return maxProxyUses; } set { maxProxyUses = value; OnPropertyChanged(); } } private bool banProxyAfterGoodStatus = false; /// Whether to ban the proxy after a SUCCESS, CUSTOM or NONE status (not FAIL or RETRY). public bool BanProxyAfterGoodStatus { get { return banProxyAfterGoodStatus; } set { banProxyAfterGoodStatus = value; OnPropertyChanged(); } } #endregion #region Data private bool encodeData = false; /// Whether the data should be URLencoded after being sliced. public bool EncodeData { get { return encodeData; } set { encodeData = value; OnPropertyChanged(); } } private string allowedWordlist1 = ""; /// The name of the first allowed WordlistType. public string AllowedWordlist1 { get { return allowedWordlist1; } set { allowedWordlist1 = value; OnPropertyChanged(); } } private string allowedWordlist2 = ""; /// The name of the second allowed WordlistType. public string AllowedWordlist2 { get { return allowedWordlist2; } set { allowedWordlist2 = value; OnPropertyChanged(); } } /// The collection of data rules that check if a data line is valid. public ObservableCollection DataRules { get; set; } = new ObservableCollection(); #endregion #region Inputs /// The collection of custom inputs that the Runner asks to the user upon start. public ObservableCollection CustomInputs { get; set; } = new ObservableCollection(); #endregion #region Selenium private bool forceHeadless = false; /// Whether to override the default choice of the user and force headless mode. public bool ForceHeadless { get { return forceHeadless; } set { forceHeadless = value; OnPropertyChanged(); } } private bool alwaysOpen = false; /// Whether to always open a browser at the start of the checking process (if not already open). public bool AlwaysOpen { get { return alwaysOpen; } set { alwaysOpen = value; OnPropertyChanged(); } } private bool alwaysQuit = false; /// Whether to always quit the browser and dispose of the WebDriver at the end of the checking process (if any browser is open). public bool AlwaysQuit { get { return alwaysQuit; } set { alwaysQuit = value; OnPropertyChanged(); } } private bool disableNotifications = false; /// Whether to disable notifications the lock the page and make it impossible to proceed. public bool DisableNotifications { get { return disableNotifications; } set { disableNotifications = value; OnPropertyChanged(); } } private string customUserAgent = ""; /// The custom User-Agent header that should be used for every request of the browser. public string CustomUserAgent { get { return customUserAgent; } set { customUserAgent = value; OnPropertyChanged(); } } private bool randomUA = false; /// Whether to choose a random User-Agent header when opening a browser instance. public bool RandomUA { get { return randomUA; } set { randomUA = value; OnPropertyChanged(); } } private string customCMDArgs = ""; /// The custom command line arguments that are sent when running the executable file. public string CustomCMDArgs { get { return customCMDArgs; } set { customCMDArgs = value; OnPropertyChanged(); } } #endregion #region Methods /// /// Removes a DataRule given its id. /// /// The unique id of the DataRule public void RemoveDataRuleById(int id) { DataRules.Remove(GetDataRuleById(id)); } /// /// Gets a DataRule given its id. /// /// The unique id of the DataRule /// The DataRule public DataRule GetDataRuleById(int id) { return DataRules.FirstOrDefault(r => r.Id == id); } /// /// Removes a CustomInput given its id. /// /// The unique id of the CustomInput public void RemoveCustomInputById(int id) { CustomInputs.Remove(GetCustomInputById(id)); } /// /// Gets a CustomInput given its id. /// /// The unique id of the CustomInput /// The CustomInput public CustomInput GetCustomInputById(int id) { return CustomInputs.FirstOrDefault(c => c.Id == id); } #endregion } }