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
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.
Delete(IReadOnlyList<string>, CancellationToken)
Deletes endpoints by ID; an ID not stored is skipped.
Task Delete(IReadOnlyList<string> ids, CancellationToken cancellationToken)
Parameters
idsIReadOnlyList<string>The IDs.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.
DeleteAll(DeleteAllOptions, CancellationToken)
Deletes the endpoints the options select.
Task DeleteAll(DeleteAllOptions options, CancellationToken cancellationToken)
Parameters
optionsDeleteAllOptionsThe groups of endpoints to delete.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.
DisableAllFailed(CancellationToken)
Disables every endpoint used whose last use did not succeed.
Task DisableAllFailed(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.
Get(string, CancellationToken)
Gets an endpoint by its ID.
Task<ProxyEndPointRecord?> Get(string id, CancellationToken cancellationToken)
Parameters
idstringThe endpoint's Id.
cancellationTokenCancellationTokenThe 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
cancellationTokenwas canceled.
GetQueuePosition(CancellationToken)
Gets the queue position, the count of connections the endpoints' rotation has reached.
Task<long> GetQueuePosition(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.
List(CancellationToken)
Lists every endpoint.
Task<IReadOnlyList<ProxyEndPointRecord>> List(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<IReadOnlyList<ProxyEndPointRecord>>
A task whose result is the endpoints, in no set order.
Exceptions
- OperationCanceledException
cancellationTokenwas 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
optionsProxyEndPointStoreListParamsThe filter and the page.
cancellationTokenCancellationTokenThe 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
cancellationTokenwas 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
newEndPointsIReadOnlyList<ProxyEndPoint>The new list.
maxItemCountint?How many endpoints to keep, or null for the default.
maxPenaltyint?The penalty above which a used endpoint goes after the new ones, or null for the default.
removeDuplicateIpsbooltrue to drop a new endpoint whose host and protocol match a stored one whose last use succeeded.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ArgumentException
maxItemCountis 0 or less.- OperationCanceledException
cancellationTokenwas canceled.
ResetStatuses(CancellationToken)
Clears every endpoint's status, and the queue position.
Task ResetStatuses(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.
SetCountryCode(string, string?, CancellationToken)
Sets the country code of a stored endpoint.
Task SetCountryCode(string id, string? countryCode, CancellationToken cancellationToken)
Parameters
idstringThe endpoint's ID; an ID not stored changes nothing.
countryCodestringThe country code, or null to clear it.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.
SetQueuePosition(long, CancellationToken)
Sets the queue position, the count of connections the endpoints' rotation has reached.
Task SetQueuePosition(long queuePosition, CancellationToken cancellationToken)
Parameters
queuePositionlongThe queue position.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- OperationCanceledException
cancellationTokenwas 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
infosIReadOnlyList<ProxyEndPointInfo>The endpoints and their statuses.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- OperationCanceledException
cancellationTokenwas 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
recordsIReadOnlyList<ProxyEndPointRecord>The endpoints.
keepExistingStatusbooltrue to keep a stored endpoint's status.
keepExistingEnabledbooltrue to keep whether a stored endpoint is enabled.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.