Table of Contents

Interface IDesktopPlatform

Namespace
VpnHood.AppUi.Hosting.Desktop.Daemon.Platform
Assembly
VpnHood.AppUi.Hosting.Desktop.Daemon.dll

Defines what the platform says for itself: the answers every command reaches for that are not the app's, and the ones only some platforms have.

public interface IDesktopPlatform

Remarks

A platform package implements it and hands it to DesktopHost with the head's init params.

Properties

Channel

Gets where the service hands its API's address to an administrator.

IDaemonChannel Channel { get; }

Property Value

IDaemonChannel

DaemonHostFactory

Gets how the app is built for daemon, which the system's service manager runs, and dev.

IAppDaemonHostFactory DaemonHostFactory { get; }

Property Value

IAppDaemonHostFactory

DesktopSession

Gets the desktop session this launch runs in, as the window's single instance asks it.

IDesktopSession DesktopSession { get; }

Property Value

IDesktopSession

Instance

Gets the running instance, as the commands start, stop and look at it.

IAppInstanceController Instance { get; }

Property Value

IAppInstanceController

InstanceSetup

Gets the registering and removal of the instance, where the app does it itself, as on Windows; or null where the package's installer does, as on Linux, and then those commands are not offered.

IAppInstanceSetup? InstanceSetup { get; }

Property Value

IAppInstanceSetup

Paths

Gets where the install keeps things.

IAppDesktopPaths Paths { get; }

Property Value

IAppDesktopPaths

PeerCheck

Gets how the system tells who owns the far end of a loopback connection, checked before a call is sent.

ILoopbackPeerCheck PeerCheck { get; }

Property Value

ILoopbackPeerCheck

Methods

CreateConsoleLoggerProvider()

Creates the console's log as the platform has it, for the process that holds the app: the journal's where standard output is the journal, as on Linux under systemd, a terminal's otherwise.

ILoggerProvider CreateConsoleLoggerProvider()

Returns

ILoggerProvider

The log's provider.

CreateSystemLogLoggerProvider()

Creates the platform's own log, for the window, which has no console: its warnings and errors go where service log looks when the service gives none, the Application log on Windows and the journal on Linux.

ILoggerProvider CreateSystemLogLoggerProvider()

Returns

ILoggerProvider

The log's provider.

HostDaemon(DaemonRun, CancellationToken)

Runs the service as the platform's service manager hosts it, with the time the stop leaves the app's graceful close, so the adapter is released before the manager ends the process.

Task<int> HostDaemon(DaemonRun run, CancellationToken cancellationToken)

Parameters

run DaemonRun

The service's run.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<int>

A task whose result is the process's exit code.

Remarks

Windows' service control manager stops it with a call, which cancels the run, and a shutdown leaves the graceful close no time; where a signal stops it, as on Linux, HostDaemonStoppedBySignal(DaemonRun, CancellationToken) runs it.

IsAdministrator()

Gets whether whoever runs this process may use the app: an administrator, by the rule the service applies to every caller of its channel.

bool IsAdministrator()

Returns

bool

true where they may.

Remarks

The window and the commands ask it first, so a standard user is told at once; the service's own check stays the boundary.

Exceptions

InvalidOperationException

The platform could not read who runs this process.

RunKillSwitchOffScript(string, CancellationToken)

Runs the installer's way out of the kill switch's block as an administrator, and waits for it, for kill-switch off when the service is not running.

Task<int> RunKillSwitchOffScript(string scriptPath, CancellationToken cancellationToken)

Parameters

scriptPath string

The script (KillSwitchOffScriptPath).

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<int>

A task whose result is the script's exit code.

Exceptions

OperationCanceledException

cancellationToken was canceled.

InvalidOperationException

The script could not be started.

StartUiAgain(bool)

Starts the window again, as it was started, through the install's own launcher, which runs the version the install names now, as after an update replaced the service under the open window; nothing for a copy run where it lies.

void StartUiAgain(bool startHidden)

Parameters

startHidden bool

true to start it in the tray.

Remarks

The window runs in a process of its own, which outlives this one.

Exceptions

InvalidOperationException

The launcher could not be started.