Table of Contents

Class WindowsInProcessDevice

Namespace
VpnHood.Core.Client.VpnServices.Host.WindowsTun
Assembly
VpnHood.Core.Client.VpnServices.Host.WindowsTun.dll

Represents a Windows device whose VPN service runs in this process, for a head that runs both halves in its one process: a developer's (AvaloniaUI.Dev), whose debugger then follows the tunnel too, or a MAUI app's, which has no daemon.

public sealed class WindowsInProcessDevice : WindowsDevice, IDevice, IDisposable
Inheritance
WindowsInProcessDevice
Implements
Inherited Members

Remarks

A head with a daemon never makes one: it compiles against nothing of the VPN service's side, and its device starts the VPN host (docs/client-architecture.md). The VPN service's lines go to the app's log, as vpn.log is the VPN host's. A session's end disposes the VPN service; the next connect makes another.

Constructors

WindowsInProcessDevice(string, bool)

Represents a Windows device whose VPN service runs in this process, for a head that runs both halves in its one process: a developer's (AvaloniaUI.Dev), whose debugger then follows the tunnel too, or a MAUI app's, which has no daemon.

public WindowsInProcessDevice(string storageFolder, bool isDebugMode)

Parameters

storageFolder string

The app's storage, with the VPN service's folder under it; the kill switch's owner.

isDebugMode bool

true to offer the split by app with test entries, as a debug build does.

Remarks

A head with a daemon never makes one: it compiles against nothing of the VPN service's side, and its device starts the VPN host (docs/client-architecture.md). The VPN service's lines go to the app's log, as vpn.log is the VPN host's. A session's end disposes the VPN service; the next connect makes another.

Methods

Dispose(bool)

Has the VPN host killed, if it runs, without waiting for its exit, where disposing is set.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true when called from Dispose(); false from a finalizer.

Remarks

It ends the VPN service in this process at once, if there is one.

StartVpnService(CancellationToken)

Starts the VPN service, which then connects as its options in the config folder say. The task completes once the start is under way, not when the VPN is up; the app's service manager waits for that.

public override Task StartVpnService(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Remarks

iOS fails it with an NSErrorException of its own.

Exceptions

VpnServiceException

Android could not start the service.

InvalidOperationException

A desktop's VPN host or the Windows VPN plug-in's profile is missing or failed.

ObjectDisposedException

A desktop's VPN host process was disposed.

TimeoutException

The Windows VPN plug-in did not start in time.

Win32Exception

Windows refused the VPN host's process.

OperationCanceledException

cancellationToken was canceled.

InvalidOperationException

The device has no VPN host, and no override starts the service.

SocketException

The VPN service could not listen for the app.

IOException

The VPN service could not publish its channel's file.