106 lines
4.5 KiB
C#
106 lines
4.5 KiB
C#
namespace ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient;
|
|
|
|
/// <summary>
|
|
/// OPC UA Client (gateway) driver configuration. Bound from <c>DriverConfig</c> JSON at
|
|
/// driver-host registration time. Models the settings documented in
|
|
/// <c>docs/v2/driver-specs.md</c> §8.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This driver connects to a REMOTE OPC UA server and re-exposes its address space
|
|
/// through the local OtOpcUa server — the opposite direction from the usual "server
|
|
/// exposes PLC data" flow. Tier A (pure managed, OPC Foundation reference SDK); universal
|
|
/// protections cover it.
|
|
/// </remarks>
|
|
public sealed class OpcUaClientDriverOptions
|
|
{
|
|
/// <summary>Remote OPC UA endpoint URL, e.g. <c>opc.tcp://plc.internal:4840</c>.</summary>
|
|
public string EndpointUrl { get; init; } = "opc.tcp://localhost:4840";
|
|
|
|
/// <summary>Security policy. One of <c>None</c>, <c>Basic256Sha256</c>, <c>Aes128_Sha256_RsaOaep</c>.</summary>
|
|
public string SecurityPolicy { get; init; } = "None";
|
|
|
|
/// <summary>Security mode.</summary>
|
|
public OpcUaSecurityMode SecurityMode { get; init; } = OpcUaSecurityMode.None;
|
|
|
|
/// <summary>Authentication type.</summary>
|
|
public OpcUaAuthType AuthType { get; init; } = OpcUaAuthType.Anonymous;
|
|
|
|
/// <summary>User name (required only for <see cref="OpcUaAuthType.Username"/>).</summary>
|
|
public string? Username { get; init; }
|
|
|
|
/// <summary>Password (required only for <see cref="OpcUaAuthType.Username"/>).</summary>
|
|
public string? Password { get; init; }
|
|
|
|
/// <summary>Server-negotiated session timeout. Default 120s per driver-specs.md §8.</summary>
|
|
public TimeSpan SessionTimeout { get; init; } = TimeSpan.FromSeconds(120);
|
|
|
|
/// <summary>Client-side keep-alive interval.</summary>
|
|
public TimeSpan KeepAliveInterval { get; init; } = TimeSpan.FromSeconds(5);
|
|
|
|
/// <summary>Initial reconnect delay after a session drop.</summary>
|
|
public TimeSpan ReconnectPeriod { get; init; } = TimeSpan.FromSeconds(5);
|
|
|
|
/// <summary>
|
|
/// When <c>true</c>, the driver accepts any self-signed / untrusted server certificate.
|
|
/// Dev-only — must be <c>false</c> in production so MITM attacks against the opc.tcp
|
|
/// channel fail closed.
|
|
/// </summary>
|
|
public bool AutoAcceptCertificates { get; init; } = false;
|
|
|
|
/// <summary>
|
|
/// Application URI the driver reports during session creation. Must match the
|
|
/// subject-alt-name on the client certificate if one is used, which is why it's a
|
|
/// config knob rather than hard-coded.
|
|
/// </summary>
|
|
public string ApplicationUri { get; init; } = "urn:localhost:OtOpcUa:GatewayClient";
|
|
|
|
/// <summary>
|
|
/// Friendly name sent to the remote server for diagnostics. Shows up in the remote
|
|
/// server's session-list so operators can identify which gateway instance is calling.
|
|
/// </summary>
|
|
public string SessionName { get; init; } = "OtOpcUa-Gateway";
|
|
|
|
/// <summary>Connect + per-operation timeout.</summary>
|
|
public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(10);
|
|
|
|
/// <summary>
|
|
/// Root NodeId to mirror. Default <c>null</c> = <c>ObjectsFolder</c> (i=85). Set to
|
|
/// a scoped root to restrict the address space the driver exposes locally — useful
|
|
/// when the remote server has tens of thousands of nodes and only a subset is
|
|
/// needed downstream.
|
|
/// </summary>
|
|
public string? BrowseRoot { get; init; }
|
|
|
|
/// <summary>
|
|
/// Cap on total nodes discovered during <c>DiscoverAsync</c>. Default 10_000 —
|
|
/// bounds memory on runaway remote servers without being so low that normal
|
|
/// deployments hit it. When the cap is reached discovery stops and a warning is
|
|
/// written to the driver health surface; the partially-discovered tree is still
|
|
/// projected into the local address space.
|
|
/// </summary>
|
|
public int MaxDiscoveredNodes { get; init; } = 10_000;
|
|
|
|
/// <summary>
|
|
/// Max hierarchical depth of the browse. Default 10 — deep enough for realistic
|
|
/// OPC UA information models, shallow enough that cyclic graphs can't spin the
|
|
/// browse forever.
|
|
/// </summary>
|
|
public int MaxBrowseDepth { get; init; } = 10;
|
|
}
|
|
|
|
/// <summary>OPC UA message security mode.</summary>
|
|
public enum OpcUaSecurityMode
|
|
{
|
|
None,
|
|
Sign,
|
|
SignAndEncrypt,
|
|
}
|
|
|
|
/// <summary>User authentication type sent to the remote server.</summary>
|
|
public enum OpcUaAuthType
|
|
{
|
|
Anonymous,
|
|
Username,
|
|
Certificate,
|
|
}
|