Class VpnHoodWindowsApp
- Namespace
- VpnHood.AppLib.App.WindowsTun
- Assembly
- VpnHood.AppLib.App.WindowsTun.dll
Provides the app as Windows runs it: in a service, one per app ID, with the VPN service in a process of its own, the VPN host, which the service starts at a connect; or, with a head's own device, in the head's one process.
public class VpnHoodWindowsApp : Singleton<VpnHoodWindowsApp>, IAsyncDisposable
- Inheritance
-
VpnHoodWindowsApp
- Implements
- Inherited Members
Remarks
What a window shows of it runs in the person's own process, over the API. Stopping it is disposing it, asynchronously, which tries to take the tunnel down before the process ends.
Methods
Dispose(bool)
Releases the instance; with disposing and when it is the registered one, unregisters it.
protected override void Dispose(bool disposing)
Parameters
Remarks
It does not disconnect the VPN first, as DisposeAsync() does; a second call does nothing.
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
Remarks
It tries to disconnect the VPN first; a failure to disconnect is logged, not thrown.
Init(AppInitParams, VpnHoodWindowsAppPaths, IDevice?)
Starts the app, once: it takes the single-instance lock before anything is built, then starts the app; a second call with no device gives the app started already.
public static VpnHoodWindowsApp Init(AppInitParams initParams, VpnHoodWindowsAppPaths paths, IDevice? device = null)
Parameters
initParamsAppInitParamsThe init params.
pathsVpnHoodWindowsAppPathsWhere the app keeps things, as its host decides.
deviceIDeviceThe head's own device, where the head runs the VPN service in its one process, as a MAUI app does; or null for the daemon's, which starts the VPN host. The app owns it from here.
Returns
- VpnHoodWindowsApp
The app.
Remarks
The service's lock is one per app ID on the machine; a run as the person keeps its lock in the paths' lock folder. An ad provider that names countries both to include and to exclude fails the start.
Exceptions
- OverflowException
A duration in a built-in access key is out of range.
- InvalidDataException
A built-in access key decodes to JSON
null.- JsonException
A built-in access key holds no valid access key.
- NotSupportedException
A built-in access key's version is not one the app reads.
- FormatException
A built-in access key is no valid Base64, or an endpoint or a duration in it is not valid.
- Win32Exception
Windows refused the administrators' namespace the service's lock is made in, as for a standard user, or, with no device given, the job the VPN host is to run in.
- AnotherInstanceIsRunningException
Another instance of the app holds the lock.
- InvalidOperationException
The app has started already, and a device is given; or the core app has started already, outside this class.
- ArgumentException
pathsnames no VPN host, and no device is given.