Interface IProxyEndPointsApi
- Namespace
- VpnHood.AppLib.Api
- Assembly
- VpnHood.AppLib.Api.dll
Represents the app's API for its proxy servers: the list the VPN may reach its server through, with each one's state.
public interface IProxyEndPointsApi
Remarks
A failure comes as IAppApi describes, in process and over HTTP.
Methods
Add(ProxyEndPoint, CancellationToken)
Adds a proxy, or updates the saved one with the same address, keeping how it has behaved.
Task<AppProxyEndPointInfo> Add(ProxyEndPoint proxyEndPoint, CancellationToken cancellationToken)
Parameters
proxyEndPointProxyEndPointThe proxy.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<AppProxyEndPointInfo>
A task whose result is the proxy, with its state.
Exceptions
- NotSupportedException
The scheme names no proxy protocol the app speaks.
- ArgumentException
The proxy's address is empty, not valid, or has no scheme or no host.
- ApiException
Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
Delete(string, CancellationToken)
Deletes a proxy.
Task Delete(string proxyEndPointId, CancellationToken cancellationToken)
Parameters
proxyEndPointIdstringThe proxy's ID.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ApiException
Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
DeleteAll(bool, bool, bool, bool, CancellationToken)
Deletes the proxies in the given states.
Task DeleteAll(bool deleteSucceeded, bool deleteFailed, bool deleteUnknown, bool deleteDisabled, CancellationToken cancellationToken)
Parameters
deleteSucceededbooltrue to delete the proxies that last succeeded.
deleteFailedbooltrue to delete the proxies that last failed.
deleteUnknownbooltrue to delete the proxies not tried yet.
deleteDisabledbooltrue to delete the disabled proxies.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ApiException
Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
DisableAllFailed(CancellationToken)
Disables every proxy that last failed.
Task DisableAllFailed(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ApiException
Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
Get(string, CancellationToken)
Gets a proxy.
Task<AppProxyEndPointInfo> Get(string proxyEndPointId, CancellationToken cancellationToken)
Parameters
proxyEndPointIdstringThe proxy's ID.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<AppProxyEndPointInfo>
A task whose result is the proxy, with its state.
Exceptions
- KeyNotFoundException
No proxy has
proxyEndPointId.- ApiException
Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
GetDevice(CancellationToken)
Gets the device's own proxy, as its settings tell it.
Task<AppProxyEndPointInfo?> GetDevice(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<AppProxyEndPointInfo>
A task whose result is the proxy, or null where the device has none.
Exceptions
- ApiException
Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
Import(string, CancellationToken)
Adds the proxies a text lists.
Task Import(string content, CancellationToken cancellationToken)
Parameters
contentstringThe text, one proxy per line.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ArgumentException
The settings' most proxies to keep is 0 or less.
- ApiException
Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
List(string?, bool, bool, bool, bool, int?, int?, CancellationToken)
Lists the proxies in the given states, a page at a time.
Task<ListResult<AppProxyEndPointInfo>> List(string? search, bool includeSucceeded, bool includeFailed, bool includeUnknown, bool includeDisabled, int? recordIndex, int? recordCount, CancellationToken cancellationToken)
Parameters
searchstringA text the proxies must contain, or null for all.
includeSucceededbooltrue to include the proxies that last succeeded.
includeFailedbooltrue to include the proxies that last failed.
includeUnknownbooltrue to include the proxies not tried yet.
includeDisabledbooltrue to include the disabled proxies.
recordIndexint?The index of the page's first proxy, or null for the first.
recordCountint?How many proxies the page holds at most, or null for all.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<ListResult<AppProxyEndPointInfo>>
A task whose result is the page, with the count of all the proxies that match.
Exceptions
- ApiException
Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
Parse(string, ProxyEndPointDefaults, CancellationToken)
Reads a proxy from its text, without adding it.
Task<AppProxyEndPointInfo> Parse(string text, ProxyEndPointDefaults defaults, CancellationToken cancellationToken)
Parameters
textstringThe proxy's address, as a URL or as a host and port.
defaultsProxyEndPointDefaultsWhat the text leaves out, as the protocol and port.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<AppProxyEndPointInfo>
A task whose result is the proxy, without a state.
Exceptions
- NotSupportedException
The scheme names no proxy protocol the app speaks.
- ArgumentException
The text is empty, not valid, or has no host; or it names no scheme and no port the defaults can place.
- ApiException
Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
ReloadUrl(CancellationToken)
Reads the proxy list again from the address the settings' automatic update names.
Task ReloadUrl(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- HttpRequestException
The list could not be read.
- InvalidOperationException
The settings name no address to read the list from.
- ArgumentException
The settings' most proxies to keep is 0 or less.
- ApiException
Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
ResetStates(CancellationToken)
Forgets every proxy's state, so each is tried anew.
Task ResetStates(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Remarks
A disabled proxy stays disabled.
Exceptions
- ApiException
Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
Update(string, ProxyEndPoint, CancellationToken)
Changes a proxy.
Task<AppProxyEndPointInfo> Update(string proxyEndPointId, ProxyEndPoint proxyEndPoint, CancellationToken cancellationToken)
Parameters
proxyEndPointIdstringThe proxy's ID.
proxyEndPointProxyEndPointThe proxy as it is to be.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<AppProxyEndPointInfo>
A task whose result is the proxy, with its state.
Exceptions
- NotSupportedException
The scheme names no proxy protocol the app speaks.
- ArgumentException
The proxy's address is empty, not valid, or has no scheme or no host.
- KeyNotFoundException
No proxy has
proxyEndPointId.- ApiException
Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.