Class EndPointResolver
- Namespace
- VpnHood.Core.Client.Abstractions
- Assembly
- VpnHood.Core.Client.Abstractions.dll
Provides the resolution of a server token's endpoints: its host name's addresses and those it lists, in the order an EndPointStrategy says.
public static class EndPointResolver
- Inheritance
-
EndPointResolver
- Inherited Members
Methods
ResolveHostEndPoints(ServerToken, EndPointStrategy, CancellationToken, ISocketFactory?)
Resolves a server token's endpoints, as ResolveHostEndPointsAndName(ServerToken, EndPointStrategy, CancellationToken, ISocketFactory?, HostNameAddresses?) does.
public static Task<IPEndPoint[]> ResolveHostEndPoints(ServerToken serverToken, EndPointStrategy strategy, CancellationToken cancellationToken, ISocketFactory? ownResolverSocketFactory = null)
Parameters
serverTokenServerTokenThe server token.
strategyEndPointStrategyThe order, or Auto for the token's own.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
ownResolverSocketFactoryISocketFactoryThe factory of sockets to ask the network's resolvers from this process, as where the kill switch's block lets only the VPN service's traffic out, or null for the system's resolver. The network's resolvers are asked in turn, over UDP and for IPv4 addresses only, five seconds each, and the first answer is taken; the system's resolver is not asked then.
Returns
- Task<IPEndPoint[]>
A task whose result is the endpoints, without repeats but for IpOnly's, which are the token's list as it is.
Exceptions
- InvalidOperationException
The token has neither endpoints nor a real host name.
- EndPointDiscoveryException
No endpoint was found.
- OperationCanceledException
cancellationTokenwas canceled.
ResolveHostEndPointsAndName(ServerToken, EndPointStrategy, CancellationToken, ISocketFactory?, HostNameAddresses?)
Resolves a server token's endpoints: its host name's addresses, where it is a real one, and those it lists, ordered as the strategy says.
public static Task<ResolvedHostEndPoints> ResolveHostEndPointsAndName(ServerToken serverToken, EndPointStrategy strategy, CancellationToken cancellationToken, ISocketFactory? ownResolverSocketFactory = null, HostNameAddresses? knownAddresses = null)
Parameters
serverTokenServerTokenThe server token.
strategyEndPointStrategyThe order, or Auto for the token's own. IpOnly with no endpoints listed falls back to DnsOnly, and that with no real host name to Auto.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
ownResolverSocketFactoryISocketFactoryThe factory of sockets to ask the network's resolvers from this process, as where the kill switch's block lets only the VPN service's traffic out, or null for the system's resolver. The network's resolvers are asked in turn, over UDP and for IPv4 addresses only, five seconds each, and the first answer is taken; the system's resolver is not asked then.
knownAddressesHostNameAddressesThe host name's addresses, known already, which are taken rather than asking the name where theirs is the token's, in any letter case, or null.
Returns
- Task<ResolvedHostEndPoints>
A task whose result is the endpoints, with those the name gave among them.
Remarks
A failure to resolve the name is logged and leaves the listed endpoints, or, under DnsOnly, none, which fails. IpOnly's endpoints are the token's list as it is; the others come without repeats.
Exceptions
- InvalidOperationException
The token has neither endpoints nor a real host name.
- EndPointDiscoveryException
No endpoint was found.
- OperationCanceledException
cancellationTokenwas canceled.