Table of Contents

Interface IOsConfigurationProvider

Namespace
VpnHood.Core.Server.OsConfiguration
Assembly
VpnHood.Core.Server.dll

Represents the server machine's operating system, as the server reads and changes it.

public interface IOsConfigurationProvider

Remarks

Each member does one thing or throws: NotSupportedException where the machine lacks what it does, such as a container's kernel settings, and any other exception where it fails. What to change, when, and what a failure means is the server's, so an implementation keeps no defaults, no state and no log.

Methods

AddIpAddress(IPAddress, string, CancellationToken)

Adds an IP address to a network interface.

Task AddIpAddress(IPAddress ipAddress, string interfaceName, CancellationToken cancellationToken)

Parameters

ipAddress IPAddress

The address.

interfaceName string

The interface's name.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that completes once the address is added.

Exceptions

ArgumentException

interfaceName is no interface name.

NotSupportedException

The machine takes no address from the server.

OperationCanceledException

cancellationToken was canceled.

GetConnectionTrackingMax(CancellationToken)

Gets the most connections the machine tracks at once, as a NAT needs.

Task<int> GetConnectionTrackingMax(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<int>

A task whose result is the number.

Exceptions

NotSupportedException

The machine tracks no connections.

OperationCanceledException

cancellationToken was canceled.

GetConnectionTrackingTcpIdleTimeout(CancellationToken)

Gets how long the machine keeps tracking an established TCP connection that sends nothing.

Task<TimeSpan> GetConnectionTrackingTcpIdleTimeout(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<TimeSpan>

A task whose result is the time.

Exceptions

NotSupportedException

The machine tracks no connections.

OperationCanceledException

cancellationToken was canceled.

GetInterfaceNames(CancellationToken)

Gets the names of the machine's network interfaces, in the machine's order, without its loopback.

Task<IReadOnlyList<string>> GetInterfaceNames(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<IReadOnlyList<string>>

A task whose result is the names.

Exceptions

NotSupportedException

The machine does not list them.

OperationCanceledException

cancellationToken was canceled.

GetSwapMemoryInfo(CancellationToken)

Gets the machine's swap memory now, the server's own swap file with it.

Task<SwapMemoryInfo> GetSwapMemoryInfo(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<SwapMemoryInfo>

A task whose result is the swap memory's sizes.

Exceptions

NotSupportedException

The machine does not tell.

OperationCanceledException

cancellationToken was canceled.

GetTcpCongestionControl(CancellationToken)

Gets the name of the TCP congestion control the machine uses, such as bbr or cubic.

Task<string> GetTcpCongestionControl(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<string>

A task whose result is the name.

Exceptions

NotSupportedException

The machine does not tell.

OperationCanceledException

cancellationToken was canceled.

IpAddressExists(IPAddress, CancellationToken)

Gets whether an IP address is on one of the machine's network interfaces.

Task<bool> IpAddressExists(IPAddress ipAddress, CancellationToken cancellationToken)

Parameters

ipAddress IPAddress

The address.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<bool>

A task whose result is true if the address is there; otherwise, false.

Exceptions

NotSupportedException

The machine does not tell.

OperationCanceledException

cancellationToken was canceled.

RemoveIpAddress(IPAddress, string)

Removes an IP address from a network interface.

void RemoveIpAddress(IPAddress ipAddress, string interfaceName)

Parameters

ipAddress IPAddress

The address.

interfaceName string

The interface's name.

Remarks

It is synchronous, as the server's quick close calls it too.

Exceptions

ArgumentException

interfaceName is no interface name.

NotSupportedException

The machine takes no change from the server.

SetAppSwapMemorySize(long, CancellationToken)

Sets the size of the server's own swap file, which an implementation may round, or take as none when small.

Task SetAppSwapMemorySize(long size, CancellationToken cancellationToken)

Parameters

size long

The size, in bytes; 0 for none.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that completes once the file has its size.

Exceptions

NotSupportedException

The machine takes no swap file from the server.

OperationCanceledException

cancellationToken was canceled.

SetConnectionTrackingMax(int, CancellationToken)

Sets the most connections the machine tracks at once.

Task SetConnectionTrackingMax(int max, CancellationToken cancellationToken)

Parameters

max int

The number.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that completes once it is set.

Exceptions

ArgumentOutOfRangeException

max is 0 or less.

NotSupportedException

The machine tracks no connections, or takes no change from the server.

OperationCanceledException

cancellationToken was canceled.

SetConnectionTrackingTcpIdleTimeout(TimeSpan, CancellationToken)

Sets how long the machine keeps tracking an established TCP connection that sends nothing.

Task SetConnectionTrackingTcpIdleTimeout(TimeSpan timeout, CancellationToken cancellationToken)

Parameters

timeout TimeSpan

The time, in whole seconds.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that completes once it is set.

Exceptions

ArgumentOutOfRangeException

timeout is under a second, or over what the machine takes.

NotSupportedException

The machine tracks no connections, or takes no change from the server.

OperationCanceledException

cancellationToken was canceled.

SetTcpCongestionControl(string, CancellationToken)

Sets the TCP congestion control the machine uses.

Task SetTcpCongestionControl(string name, CancellationToken cancellationToken)

Parameters

name string

The congestion control's name, such as bbr.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that completes once it is set.

Exceptions

ArgumentException

name is no congestion control's name.

NotSupportedException

The machine has no such congestion control, or takes no change from the server.

OperationCanceledException

cancellationToken was canceled.