Table of Contents

Class GatewayLocator

Namespace
OpenShell.Gateway
Assembly
OpenShell.Sdk.dll

Finds gateways registered on disk by the OpenShell CLI.

public sealed class GatewayLocator
Inheritance
GatewayLocator
Inherited Members

Constructors

GatewayLocator(GatewayLocatorOptions?)

Creates a locator with the default OS layout.

public GatewayLocator(GatewayLocatorOptions? options = null)

Parameters

options GatewayLocatorOptions

Properties

SystemConfigDirectory

The system-wide configuration directory, or null when none applies: SystemConfigDirectory, else $OPENSHELL_SYSTEM_GATEWAY_DIR when it is an absolute path (empty or relative values are ignored, as the CLI does), else /etc/openshell (none on Windows).

public string? SystemConfigDirectory { get; }

Property Value

string

UserConfigDirectory

The per-user configuration directory ($XDG_CONFIG_HOME/openshell or the OS default).

public string UserConfigDirectory { get; }

Property Value

string

Methods

List()

Lists registered gateways sorted by name, as the OpenShell CLI does: a user directory counts only when it holds metadata.json (and then shadows a system registration of the same name), and registrations whose metadata cannot be read are skipped.

public IReadOnlyList<GatewayEntry> List()

Returns

IReadOnlyList<GatewayEntry>

Load(string?)

Loads a gateway by name; null selects the active gateway. A user registration (one with metadata.json) shadows a system one; credentials are always read from the user gateway directory (StateDirectory).

public GatewayMetadata Load(string? name = null)

Parameters

name string

Returns

GatewayMetadata

ResolveActiveName()

Resolves the active gateway name: $OPENSHELL_GATEWAY, else the user active_gateway file, else the system active_gateway file. As in the OpenShell CLI, a missing, empty, or invalid file falls through to the next source.

public string ResolveActiveName()

Returns

string

ValidateName(string)

Validates a gateway name as a portable, single path component, as the OpenShell CLI does: ASCII letters, digits, -, _ and ., so host-derived FQDN and IPv4 names such as gw.example.com work. Rejects . and .., a leading or trailing dot, .. anywhere, and Windows device names (CON, PRN, AUX, NUL, COM0-COM9, LPT0-LPT9, also before a dot, in any case) on every platform.

public static void ValidateName(string name)

Parameters

name string