Table of Contents

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

int

DefaultMaxPenalty

The penalty above which a used endpoint goes after the new ones by default: 50.

public const int DefaultMaxPenalty = 50

Field Value

int

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

httpClient HttpClient

The client to download with.

url Uri

The text's URL.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<ProxyEndPoint[]>

A task whose result is the endpoints found.

Exceptions

HttpRequestException

The download failed.

OperationCanceledException

cancellationToken was 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

currentEndPointInfos IEnumerable<ProxyEndPointInfo>

The current endpoints and their statuses.

newEndPoints ProxyEndPoint[]

The new endpoints.

maxItemCount int?

How many endpoints to keep, or null for DefaultMaxItemCount.

maxPenalty int?

The penalty above which a used endpoint goes after the new ones, or null for DefaultMaxPenalty.

removeDuplicateIps bool

true 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

maxItemCount is 0 or less.