Table of Contents

Interface IProxyEndPointStore

Namespace
VpnHood.Core.Proxies.Management.Abstractions
Assembly
VpnHood.Core.Proxies.Management.Abstractions.dll

Defines the persistent store of a managed proxy list, which the app and the VPN service share.

public interface IProxyEndPointStore : IDisposable
Inherited Members

Remarks

An implementation must be safe to use at once from several processes on the same store. Endpoints are known by their Id.

Methods

Count(CancellationToken)

Counts the endpoints.

Task<int> Count(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<int>

A task whose result is the number of endpoints.

Exceptions

OperationCanceledException

cancellationToken was canceled.

Delete(IReadOnlyList<string>, CancellationToken)

Deletes endpoints by ID; an ID not stored is skipped.

Task Delete(IReadOnlyList<string> ids, CancellationToken cancellationToken)

Parameters

ids IReadOnlyList<string>

The IDs.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

OperationCanceledException

cancellationToken was canceled.

DeleteAll(DeleteAllOptions, CancellationToken)

Deletes the endpoints the options select.

Task DeleteAll(DeleteAllOptions options, CancellationToken cancellationToken)

Parameters

options DeleteAllOptions

The groups of endpoints to delete.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

OperationCanceledException

cancellationToken was canceled.

DisableAllFailed(CancellationToken)

Disables every endpoint used whose last use did not succeed.

Task DisableAllFailed(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

OperationCanceledException

cancellationToken was canceled.

Get(string, CancellationToken)

Gets an endpoint by its ID.

Task<ProxyEndPointRecord?> Get(string id, CancellationToken cancellationToken)

Parameters

id string

The endpoint's Id.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<ProxyEndPointRecord>

A task whose result is the endpoint, or null when there is none of the ID.

Exceptions

OperationCanceledException

cancellationToken was canceled.

GetQueuePosition(CancellationToken)

Gets the queue position, the count of connections the endpoints' rotation has reached.

Task<long> GetQueuePosition(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<long>

A task whose result is the queue position; 0 when none is stored.

Exceptions

OperationCanceledException

cancellationToken was canceled.

List(CancellationToken)

Lists every endpoint.

Task<IReadOnlyList<ProxyEndPointRecord>> List(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<IReadOnlyList<ProxyEndPointRecord>>

A task whose result is the endpoints, in no set order.

Exceptions

OperationCanceledException

cancellationToken was canceled.

List(ProxyEndPointStoreListParams, CancellationToken)

Lists a page of the endpoints that match a filter, enabled ones first, then by quality, best first, all within the store, so the caller never loads the whole list.

Task<ListResult<ProxyEndPointRecord>> List(ProxyEndPointStoreListParams options, CancellationToken cancellationToken)

Parameters

options ProxyEndPointStoreListParams

The filter and the page.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<ListResult<ProxyEndPointRecord>>

A task whose result is the page, with the number of all the matching endpoints.

Exceptions

OperationCanceledException

cancellationToken was canceled.

Merge(IReadOnlyList<ProxyEndPoint>, int?, int?, bool, CancellationToken)

Merges a new list of endpoints into the store, by Merge(IEnumerable<ProxyEndPointInfo>, ProxyEndPoint[], int?, int?, bool)'s order: it deletes the endpoints the merge leaves out and adds the new ones, in one transaction, and a stored endpoint keeps its status and enabled state.

Task Merge(IReadOnlyList<ProxyEndPoint> newEndPoints, int? maxItemCount, int? maxPenalty, bool removeDuplicateIps, CancellationToken cancellationToken)

Parameters

newEndPoints IReadOnlyList<ProxyEndPoint>

The new list.

maxItemCount int?

How many endpoints to keep, or null for the default.

maxPenalty int?

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

removeDuplicateIps bool

true to drop a new endpoint whose host and protocol match a stored one whose last use succeeded.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

ArgumentException

maxItemCount is 0 or less.

OperationCanceledException

cancellationToken was canceled.

ResetStatuses(CancellationToken)

Clears every endpoint's status, and the queue position.

Task ResetStatuses(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

OperationCanceledException

cancellationToken was canceled.

SetCountryCode(string, string?, CancellationToken)

Sets the country code of a stored endpoint.

Task SetCountryCode(string id, string? countryCode, CancellationToken cancellationToken)

Parameters

id string

The endpoint's ID; an ID not stored changes nothing.

countryCode string

The country code, or null to clear it.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

OperationCanceledException

cancellationToken was canceled.

SetQueuePosition(long, CancellationToken)

Sets the queue position, the count of connections the endpoints' rotation has reached.

Task SetQueuePosition(long queuePosition, CancellationToken cancellationToken)

Parameters

queuePosition long

The queue position.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

OperationCanceledException

cancellationToken was canceled.

UpdateStatuses(IReadOnlyList<ProxyEndPointInfo>, CancellationToken)

Updates the status and the enabled state of stored endpoints, by ID. It adds none, so it cannot bring back an endpoint the other process has deleted.

Task UpdateStatuses(IReadOnlyList<ProxyEndPointInfo> infos, CancellationToken cancellationToken)

Parameters

infos IReadOnlyList<ProxyEndPointInfo>

The endpoints and their statuses.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

OperationCanceledException

cancellationToken was canceled.

Upsert(IReadOnlyList<ProxyEndPointRecord>, bool, bool, CancellationToken)

Adds endpoints, or updates those of the same IDs: their protocol, host, port, user name and password, and their country code where the record gives one.

Task Upsert(IReadOnlyList<ProxyEndPointRecord> records, bool keepExistingStatus, bool keepExistingEnabled, CancellationToken cancellationToken)

Parameters

records IReadOnlyList<ProxyEndPointRecord>

The endpoints.

keepExistingStatus bool

true to keep a stored endpoint's status.

keepExistingEnabled bool

true to keep whether a stored endpoint is enabled.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

OperationCanceledException

cancellationToken was canceled.