Table of Contents

Class SimpleProxyConnector

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

Provides the VPN's connections through one given proxy, such as the device's: nothing is saved, rated or updated.

public class SimpleProxyConnector : IProxyConnector, IAsyncDisposable
Inheritance
SimpleProxyConnector
Implements
Inherited Members

Constructors

SimpleProxyConnector(ProxyEndPoint)

Provides the VPN's connections through one given proxy, such as the device's: nothing is saved, rated or updated.

public SimpleProxyConnector(ProxyEndPoint proxyEndPoint)

Parameters

proxyEndPoint ProxyEndPoint

The proxy.

Properties

IsEnabled

Gets a value indicating whether the connector has a proxy to connect through.

public bool IsEnabled { get; }

Property Value

bool

Always true.

Progress

Gets the progress of a check of the endpoints under way, or null.

public ProgressStatus? Progress { get; }

Property Value

ProgressStatus?

Always null: there is no check.

Status

Gets the connector's state, made at each read.

public ProxyConnectorStatus Status { get; }

Property Value

ProxyConnectorStatus

Remarks

It counts the one proxy by the outcome of its last connection.

UseRecentSucceeded

Gets or sets a value indicating whether connections use only the endpoints that have succeeded since the connector was made, where there is a list to choose from.

public bool UseRecentSucceeded { get; set; }

Property Value

bool

Remarks

It changes nothing here: there is one proxy.

Methods

CheckServers(ISocketFactory, CancellationToken)

Checks the endpoints, where the connector has a list to check, and records what it finds.

public Task CheckServers(ISocketFactory socketFactory, CancellationToken cancellationToken)

Parameters

socketFactory ISocketFactory

The factory of the sockets to the proxies, which keeps them out of the tunnel.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Remarks

It does nothing: a connection's failure tells.

ConnectAsync(ISocketFactory, IPEndPoint, Action?, CancellationToken)

Connects to an endpoint through a proxy.

public Task<TcpClient> ConnectAsync(ISocketFactory socketFactory, IPEndPoint ipEndPoint, Action? onAttempt, CancellationToken cancellationToken)

Parameters

socketFactory ISocketFactory

The factory of the sockets to the proxies: the caller's, which keeps them out of the tunnel.

ipEndPoint IPEndPoint

The endpoint to reach through the proxy.

onAttempt Action

Called after each proxy the connector tried, or null.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<TcpClient>

A task whose result is the connection, through the proxy, which the caller owns. Its stream is the raw TCP one, not an HTTPS proxy's TLS tunnel.

Remarks

A failure is counted and thrown; a cancellation of cancellationToken is not counted.

Exceptions

ProxyClientException

The proxy refused the connection, or answered in a way the client does not take.

UnauthorizedAccessException

A SOCKS5 proxy refused the credentials.

ProtocolViolationException

The proxy's answer broke its protocol.

ArgumentException

The endpoint's credentials are too long for its protocol.

AuthenticationException

The TLS handshake with an HTTPS proxy failed.

TimeoutException

The proxy took too long.

IOException

The connection to the proxy failed.

SocketException

The proxy's host could not be resolved or reached.

Exception

DNS gave no address for the proxy's host.

NotSupportedException

The proxy's protocol, a SOCKS5 proxy's authentication method, or its reply's address type is not supported.

OperationCanceledException

cancellationToken was canceled.

DisposeAsync()

Does nothing: the connector holds nothing to release.

public ValueTask DisposeAsync()

Returns

ValueTask

A completed task.

Flush(CancellationToken)

Saves the endpoints' statuses not saved yet, where the connector keeps any.

public Task Flush(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Remarks

It does nothing: nothing is saved.

RecordFailed(TcpClient, Exception)

Records a failure of a connection ConnectAsync(ISocketFactory, IPEndPoint, Action?, CancellationToken) made, after it was made, as in a TLS handshake over it, against the proxy that made it.

public void RecordFailed(TcpClient tcpClient, Exception ex)

Parameters

tcpClient TcpClient

The connection.

ex Exception

The failure.

Remarks

It counts a failure, whatever the connection.

UpdateOptions(ProxyOptions, CancellationToken)

Takes new options.

public Task UpdateOptions(ProxyOptions proxyOptions, CancellationToken cancellationToken)

Parameters

proxyOptions ProxyOptions

The options.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Remarks

It takes the options' proxy, when they give one.