using Extreme.Net; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RuriLib.Models { /// /// A remote source where proxies can be downloaded and parsed from. /// public class RemoteProxySource { /// /// Creates a RemoteProxySource given a unique ID. /// /// The unique ID public RemoteProxySource(int id) { Id = id; } /// The unique ID of the RemoteProxySource. public int Id { get; set; } = 0; /// Whether the RemoteProxySource is active or not. public bool Active { get; set; } = true; /// The Url of the remote source. public string Url { get; set; } = ""; /// The type of downloaded proxies. public ProxyType Type { get; set; } = ProxyType.Http; /// /// Whether the proxy type has been initialized. /// [JsonIgnore] public bool TypeInitialized { get; set; } = false; /// The regex pattern to match when parsing proxies from the downloaded page. Must use capture groups. // Best Regex = @"((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):[0-9]+)"; public string Pattern { get; set; } = @"([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+)"; /// The output format of the groups matched by Regex. public string Output { get; set; } = "[1]"; } /// /// The result for async download of proxies from remote sources. /// public class RemoteProxySourceResult { /// Whether the download was successful. public bool Successful { get; set; } /// The Message of the Exception thrown while downloading or parsing the proxies. public string Error { get; set; } /// The Url from which the proxies were downloaded from. public string Url { get; set; } /// The downloaded and parsed proxies. public List Proxies { get; set; } } }