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
ipAddressIPAddressThe address.
interfaceNamestringThe interface's name.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that completes once the address is added.
Exceptions
- ArgumentException
interfaceNameis no interface name.- NotSupportedException
The machine takes no address from the server.
- OperationCanceledException
cancellationTokenwas canceled.
GetConnectionTrackingMax(CancellationToken)
Gets the most connections the machine tracks at once, as a NAT needs.
Task<int> GetConnectionTrackingMax(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
Exceptions
- NotSupportedException
The machine tracks no connections.
- OperationCanceledException
cancellationTokenwas canceled.
GetConnectionTrackingTcpIdleTimeout(CancellationToken)
Gets how long the machine keeps tracking an established TCP connection that sends nothing.
Task<TimeSpan> GetConnectionTrackingTcpIdleTimeout(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
Exceptions
- NotSupportedException
The machine tracks no connections.
- OperationCanceledException
cancellationTokenwas 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
cancellationTokenCancellationTokenThe 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
cancellationTokenwas canceled.
GetSwapMemoryInfo(CancellationToken)
Gets the machine's swap memory now, the server's own swap file with it.
Task<SwapMemoryInfo> GetSwapMemoryInfo(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe 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
cancellationTokenwas 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
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
Exceptions
- NotSupportedException
The machine does not tell.
- OperationCanceledException
cancellationTokenwas 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
ipAddressIPAddressThe address.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
Exceptions
- NotSupportedException
The machine does not tell.
- OperationCanceledException
cancellationTokenwas canceled.
RemoveIpAddress(IPAddress, string)
Removes an IP address from a network interface.
void RemoveIpAddress(IPAddress ipAddress, string interfaceName)
Parameters
Remarks
It is synchronous, as the server's quick close calls it too.
Exceptions
- ArgumentException
interfaceNameis 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
sizelongThe size, in bytes; 0 for none.
cancellationTokenCancellationTokenThe 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
cancellationTokenwas canceled.
SetConnectionTrackingMax(int, CancellationToken)
Sets the most connections the machine tracks at once.
Task SetConnectionTrackingMax(int max, CancellationToken cancellationToken)
Parameters
maxintThe number.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that completes once it is set.
Exceptions
- ArgumentOutOfRangeException
maxis 0 or less.- NotSupportedException
The machine tracks no connections, or takes no change from the server.
- OperationCanceledException
cancellationTokenwas 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
timeoutTimeSpanThe time, in whole seconds.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that completes once it is set.
Exceptions
- ArgumentOutOfRangeException
timeoutis under a second, or over what the machine takes.- NotSupportedException
The machine tracks no connections, or takes no change from the server.
- OperationCanceledException
cancellationTokenwas canceled.
SetTcpCongestionControl(string, CancellationToken)
Sets the TCP congestion control the machine uses.
Task SetTcpCongestionControl(string name, CancellationToken cancellationToken)
Parameters
namestringThe congestion control's name, such as
bbr.cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that completes once it is set.
Exceptions
- ArgumentException
nameis no congestion control's name.- NotSupportedException
The machine has no such congestion control, or takes no change from the server.
- OperationCanceledException
cancellationTokenwas canceled.