Skip to main content
.NETFramework4.5.1.NETStandard2.0

C# wrapper library for Windows Filtering Platform

Published
May 19, 2022
4y ago
Total Downloads
16.3K
16,307

Install

dotnet add package H.Wfp --version 0.9.6
ProductVersions
.NET Standard
netstandard2.0
Other
.NETFramework4.5.1

README

H.Vpn

A set of C# libraries for VPN implementation

Features

  • Supports firewall that will block the internet if there are connection problems.
  • Based on OpenVPN

Nuget

NuGet
NuGet
NuGet
NuGet
NuGet

Usage

H.Firewall

Forbids for 15 seconds everything except LAN/DNS/Localhost requests and Chrome applications.
NOTE: To use this code in your application, you must either run it as an administrator or run it through a service talking to it via IPC (eg H.Pipes). Else you will get the following error: 0x8032000D. The call must be made from within an explicit transaction.

using var firewall = new HFirewall();

firewall.Start();
firewall.RunTransaction(ptr =>
{
    var (providerKey, subLayerKey) = firewall.RegisterKeys();
    firewall.PermitAppId(
        providerKey,
        subLayerKey,
        @"C:\Users\haven\AppData\Local\Google\Chrome\Application\chrome.exe",
        15);

    firewall.PermitLan(providerKey, subLayerKey, 12);
    firewall.PermitDns(providerKey, subLayerKey, 11, 10);
    firewall.PermitLocalhost(providerKey, subLayerKey, 1);

    // Block everything not allowed explicitly
    firewall.BlockAll(providerKey, subLayerKey, 0);
});

await Task.Delay(TimeSpan.FromSeconds(15));

H.Firewall uses WFP calls internally, you can learn more about this.

Usage

Contacts

Changes from Previous Version

No structural changes between v0.9.5 and v0.9.6.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.