Skip to main content

FirewallManager

Windows firewall rule management for registering inbound service rules via netsh.exe.

Usage​

import { FirewallManager } from "@io-oidis-localhost/Io/Oidis/Localhost/Utils/FirewallManager.js";

FirewallManager.AddServiceRule(
"MyGroup",
"MyService",
"My Application",
"Oidis application inbound rule",
"C:/path/to/app.exe",
() => {
// continue startup
}
);

API Reference​

AddServiceRule​

Registers an inbound Windows Firewall rule for a service executable. Executes asynchronously and calls the callback when complete (regardless of success or skip).

public static AddServiceRule(
$groupName : string,
$serviceName : string,
$appName : string,
$description : string,
$servicePath : string,
$callback : () => void
) : void
  • $groupName — firewall rule group name.
  • $serviceName — Windows service name.
  • $appName — display name of the firewall rule.
  • $description — description text for the rule.
  • $servicePath — path to the .exe file (.exe extension is appended automatically if missing).
  • $callback — called after the operation completes, whether the rule was added, skipped, or failed.

Behavior​

The method is a no-op (callback is called immediately) in the following situations:

ConditionBehavior
Non-Windows OSSkipped — logged as debug
Windows < 6.0 (Vista)Skipped — logged as debug
Not running as administratorSkipped — logged as info
Rule already exists for the pathSkipped — logged as warning

When all conditions are met, uses netsh.exe advfirewall firewall add rule with dir=in, action=allow, enable=yes, profile=any.

note

FirewallManager is a static utility class with no singleton instance. All functionality is accessed through static methods.


See also: Utilities Overview | Terminal | Localhost Overview