Table of Contents

Interface IProxyConnector

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

Defines how the VPN connects to its servers through proxies: through one given proxy, or through a managed list that rates and rotates its endpoints.

public interface IProxyConnector : IAsyncDisposable
Inherited Members

Properties

IsEnabled

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

bool IsEnabled { get; }

Property Value

bool

Progress

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

ProgressStatus? Progress { get; }

Property Value

ProgressStatus?

Status

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

ProxyConnectorStatus Status { get; }

Property Value

ProxyConnectorStatus

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.

bool UseRecentSucceeded { get; set; }

Property Value

bool

Methods

CheckServers(ISocketFactory, CancellationToken)

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

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.

ConnectAsync(ISocketFactory, IPEndPoint, Action?, CancellationToken)

Connects to an endpoint through a proxy.

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.

Flush(CancellationToken)

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

Task Flush(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

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.

void RecordFailed(TcpClient tcpClient, Exception ex)

Parameters

tcpClient TcpClient

The connection.

ex Exception

The failure.

UpdateOptions(ProxyOptions, CancellationToken)

Takes new options.

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.