using Extreme.Net;
namespace RuriLib.ViewModels
{
///
/// The Source of proxies that gets queried when all proxies are banned in order to get fresh ones.
///
public enum ProxyReloadSource
{
/// The ProxyManager.
Manager,
/// A file on the disk.
File,
/// An online API.
API
}
///
/// Provides proxy-related settings.
///
public class SettingsProxies : ViewModelBase
{
#region General
private bool concurrentUse = false;
/// Whether to allow two Bots to use the same proxy.
public bool ConcurrentUse { get { return concurrentUse; } set { concurrentUse = value; OnPropertyChanged(); } }
private bool neverBan = false;
/// Whether to never ban the proxies.
public bool NeverBan { get { return neverBan; } set { neverBan = value; OnPropertyChanged(); } }
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
private bool reload = true;
/// Whether to reload the proxies from the proxy source after they are all banned.
public bool Reload { get { return reload; } set { reload = value; OnPropertyChanged(); } }
private ProxyReloadSource reloadSource = ProxyReloadSource.Manager;
/// The source to reload the proxies from.
public ProxyReloadSource ReloadSource { get { return reloadSource; } set { reloadSource = value; OnPropertyChanged(); } }
private string reloadPath = "";
/// The API URL or the file path on disk.
public string ReloadPath { get { return reloadPath; } set { reloadPath = value; OnPropertyChanged(); } }
private ProxyType reloadType = ProxyType.Http;
/// The Type of the proxies to load.
public ProxyType ReloadType { get { return reloadType; } set { reloadType = value; OnPropertyChanged(); } }
private bool parseWithIPRegex = false;
///
/// Whether to use an IP:PORT regex to extract the proxies from the source.
/// The regex will match proxies of the form 127.0.0.1:8888.
/// This is useful for example when the server returns proxies in a HTML, XML or JSON format and not one proxy per line.
/// This is also useful when the server returns proxies with unix-like line endings.
///
public bool ParseWithIPRegex { get { return parseWithIPRegex; } set { parseWithIPRegex = value; OnPropertyChanged(); } }
#endregion
#region Cloudflare
private bool alwaysGetClearance = false;
/// Whether to avoid storing the clearance cookie for future use when querying the site from the same IP (proxy).
public bool AlwaysGetClearance { get { return alwaysGetClearance; } set { alwaysGetClearance = value; OnPropertyChanged(); } }
#endregion
#region Global Keys
private string[] globalBanKeys = new string[] { };
///
/// The array of possible bad replies from a proxy server.
/// The proxy will be banned when one of the keys is found.
/// These are useful to immediately blacklist proxies that need a captive portal or that only accept IPs from a given region.
///
public string[] GlobalBanKeys { get { return globalBanKeys; } set { globalBanKeys = value; OnPropertyChanged(); } }
private string[] globalRetryKeys = new string[] { };
///
/// The array of possible temporary bad replies from a proxy server.
/// The proxy will be retried on the next check.
/// These are useful when the proxy is temporarily too busy because of high traffic.
///
public string[] GlobalRetryKeys { get { return globalRetryKeys; } set { globalRetryKeys = value; OnPropertyChanged(); } }
#endregion
}
}