FirewallRuleKeeper
Class in Oadm.Sdk.Network · Oadm.Sdk.dll
Keeps one firewall rule in line with a service’s enabled state (NTP server, DHCP server): FirewallRuleKeeper.SyncAsync opens the rule when the service is enabled and closes it when disabled or stopped. The first call always applies the state (a rule left by a crashed server is removed), later calls only on a change. Best effort: firewall errors are logged and never fail the service. Without a host firewall (null) it does nothing. Not thread-safe: callers serialize the calls (the services call it under their own gate).
public sealed class FirewallRuleKeeperConstructors
Section titled “Constructors”FirewallRuleKeeper
Section titled “FirewallRuleKeeper”FirewallRuleKeeper(FirewallRule rule, IFirewallRules? firewall, ILogger? logger = null)Keeps rule; without firewall it does nothing.
Properties
Section titled “Properties”IsOpen
Section titled “IsOpen”bool IsOpen { get; }True once the rule was opened (and not closed since).
FirewallRule Rule { get; }The rule it keeps.
Methods
Section titled “Methods”SyncAsync
Section titled “SyncAsync”Task SyncAsync(bool enabled, CancellationToken ct)Opens the rule when enabled, closes it otherwise.