Class ProxyEndPointUpdater
- Namespace
- VpnHood.Core.Proxies.Management.Abstractions
- Assembly
- VpnHood.Core.Proxies.Management.Abstractions.dll
Provides the merge of a downloaded list of proxy endpoints into a managed list, and the download.
public static class ProxyEndPointUpdater
- Inheritance
-
ProxyEndPointUpdater
- Inherited Members
Fields
DefaultMaxItemCount
The number of endpoints a merge keeps by default: 1,000.
public const int DefaultMaxItemCount = 1000
Field Value
DefaultMaxPenalty
The penalty above which a used endpoint goes after the new ones by default: 50.
public const int DefaultMaxPenalty = 50
Field Value
Methods
LoadFromUrlAsync(HttpClient, Uri, CancellationToken)
Downloads a text and reads the proxy endpoints in it, as ExtractFromContent(string, string, bool) does.
public static Task<ProxyEndPoint[]> LoadFromUrlAsync(HttpClient httpClient, Uri url, CancellationToken cancellationToken)
Parameters
httpClientHttpClientThe client to download with.
urlUriThe text's URL.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<ProxyEndPoint[]>
A task whose result is the endpoints found.
Exceptions
- HttpRequestException
The download failed.
- OperationCanceledException
cancellationTokenwas canceled.- NotSupportedException
An address found has a scheme that is no proxy protocol.
Merge(IEnumerable<ProxyEndPointInfo>, ProxyEndPoint[], int?, int?, bool)
Merges a new list of endpoints into the current one, in order of worth, and keeps the first ones.
public static ProxyEndPoint[] Merge(IEnumerable<ProxyEndPointInfo> currentEndPointInfos, ProxyEndPoint[] newEndPoints, int? maxItemCount, int? maxPenalty, bool removeDuplicateIps = false)
Parameters
currentEndPointInfosIEnumerable<ProxyEndPointInfo>The current endpoints and their statuses.
newEndPointsProxyEndPoint[]The new endpoints.
maxItemCountint?How many endpoints to keep, or null for DefaultMaxItemCount.
maxPenaltyint?The penalty above which a used endpoint goes after the new ones, or null for DefaultMaxPenalty.
removeDuplicateIpsbooltrue to drop a new endpoint whose host, ignoring case, and protocol match a current one whose last use succeeded.
Returns
- ProxyEndPoint[]
The merged list: the enabled current endpoints used with a penalty up to
maxPenalty, by penalty; the new ones; the enabled current ones never used; the enabled current ones above the penalty; then the disabled ones. An endpoint that comes twice as the same object is kept once; one that comes as two objects, such as a new endpoint equal to a current one, is kept twice.
Exceptions
- ArgumentException
maxItemCountis 0 or less.