namespace ZB.MOM.WW.ScadaBridge.AuditLog.Central.HeadExport;
/// Where exported chain heads go.
public enum AuditChainHeadSinkKind
{
/// Append-only JSON-lines files in a directory (local or UNC).
File,
/// RFC 5424 syslog over UDP or TCP.
Syslog,
}
/// Syslog transport.
public enum AuditSyslogProtocol
{
/// One datagram per record (RFC 5426).
Udp,
/// Octet-counted frames on one TCP connection per export (RFC 6587).
Tcp,
}
///
/// Off-box export of the AuditLog hash-chain heads (section AuditLog:HashChain:HeadExport,
/// ScadaBridge#107 item 1). Default OFF. Every both central
/// nodes read each month's chain head (month, last sequence + hash, partition-purge anchor,
/// chained-row and tombstone counts) and append the heads that changed since their previous
/// export to a sink the database login cannot write. audit verify-heads later compares
/// those records with the database: a chain someone rewrote and re-hashed inside SQL Server no
/// longer carries the hash that was exported.
///
public sealed class AuditChainHeadExportOptions
{
/// Whether the export runs (default false).
public bool Enabled { get; set; }
/// Minutes between exports (default 60).
public int IntervalMinutes { get; set; } = 60;
///
/// Re-export unchanged heads every tick too (default false: only heads whose sequence,
/// anchor or counts moved since this node's previous export, plus every head on the first
/// tick after start).
///
public bool ExportUnchanged { get; set; }
/// Which sink (default ).
public AuditChainHeadSinkKind Sink { get; set; } = AuditChainHeadSinkKind.File;
/// File sink settings.
public AuditChainHeadFileSinkOptions File { get; set; } = new();
/// Syslog sink settings.
public AuditChainHeadSyslogSinkOptions Syslog { get; set; } = new();
}
/// File sink: {Directory}/{yyyy}/audit-chain-heads-{yyyy-MM-dd}-{node}.jsonl, opened for append only.
public sealed class AuditChainHeadFileSinkOptions
{
///
/// Absolute directory (local path or UNC share). Give the service account create + append
/// rights only; the SQL Server login has no access to it by construction.
///
public string? Directory { get; set; }
}
/// Syslog sink (RFC 5424).
public sealed class AuditChainHeadSyslogSinkOptions
{
/// Collector host name or address.
public string? Host { get; set; }
/// Collector port (default 514).
public int Port { get; set; } = 514;
/// Transport (default UDP).
public AuditSyslogProtocol Protocol { get; set; } = AuditSyslogProtocol.Udp;
/// Syslog facility 0–23 (default 13, "log audit").
public int Facility { get; set; } = 13;
/// APP-NAME field (default scadabridge).
public string AppName { get; set; } = "scadabridge";
/// Send/connect timeout in seconds (default 10).
public int TimeoutSeconds { get; set; } = 10;
}