Class VpnHoodClientFactory
Represents the default composition of a VpnHoodClient: it turns VpnServiceOptions into the services the client needs — the split filters, the proxy connector, the tracker — and makes the client.
public class VpnHoodClientFactory
- Inheritance
-
VpnHoodClientFactory
- Inherited Members
Remarks
Create(VpnHoodClientParams, NetFilter, CancellationToken) is the skeleton and each step is virtual, so a derived factory replaces a single piece and inherits the rest. The host gets the factory for each connection from CreateClientFactory(), composes the client's filter, and keeps ownership of the made client. The filters update themselves — their stages read the filter folders' manifests again when a reconfigure rolls down them — so nothing here is kept for live updates.
Methods
Create(VpnHoodClientParams, NetFilter, CancellationToken)
Makes the client for a connection.
public virtual Task<VpnHoodClient> Create(VpnHoodClientParams clientParams, NetFilter netFilter, CancellationToken cancellationToken)
Parameters
clientParamsVpnHoodClientParamsWhat the host prepared for the connection.
netFilterNetFilterThe client's filter, which the host composed and the client owns once it is made.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<VpnHoodClient>
A task whose result is the client.
Exceptions
- FormatException
The access key is not one.
- NotSupportedException
The access key's version is not 4.
- JsonException
The access key's JSON is not valid.
- InvalidDataException
The access key's JSON is
null.- OverflowException
A duration in the access key is out of range.
- InvalidOperationException
The access key has no farm secret.
- ArgumentNullException
The options' longest packet channel life, where finite, is below their shortest.
- OperationCanceledException
cancellationTokenwas canceled.
CreateInnerDomainFilter(VpnHoodClientParams)
Makes the domain filter under the split-domain gates. Unlike the IP one (CreateInnerIpFilter(VpnHoodClientParams)), it comes second: it hears only of a domain the gates leave to it, so a gate's include wins over its block. By default there is none.
protected virtual IDomainFilter? CreateInnerDomainFilter(VpnHoodClientParams clientParams)
Parameters
clientParamsVpnHoodClientParamsWhat the host prepared for the connection.
Returns
- IDomainFilter
The filter, or null for none under the gates.
CreateInnerIpFilter(VpnHoodClientParams)
Makes the filter the split-IP gates chain over, which is evaluated first and whose veto wins: a derived factory's own policy under the gates. By default there is none.
protected virtual IIpFilter? CreateInnerIpFilter(VpnHoodClientParams clientParams)
Parameters
clientParamsVpnHoodClientParamsWhat the host prepared for the connection.
Returns
CreateIpMapper(VpnHoodClientParams)
Makes the mapper of the client's destinations, a derived factory's, as tests map fake addresses to mock servers. By default there is none.
public virtual IIpMapper? CreateIpMapper(VpnHoodClientParams clientParams)
Parameters
clientParamsVpnHoodClientParamsWhat the host prepared for the connection.
Returns
CreateProxyConnector(VpnHoodClientParams, CancellationToken)
Makes the connector of the person's proxies: a simple one for a single proxy, without a store; a managed one over the SQLite store the app's process shares; or none, so connections go direct.
protected virtual Task<IProxyConnector?> CreateProxyConnector(VpnHoodClientParams clientParams, CancellationToken cancellationToken)
Parameters
clientParamsVpnHoodClientParamsWhat the host prepared for the connection.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<IProxyConnector>
A task whose result is the connector, or null for none.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.
CreateTracker(VpnHoodClientParams)
Makes the app's trackers again in this process, from their factories' types (TrackerFactoryInfos), switched on or off as AllowAnonymousTracker says.
protected virtual ITracker? CreateTracker(VpnHoodClientParams clientParams)
Parameters
clientParamsVpnHoodClientParamsWhat the host prepared for the connection.