falahati / WindowsFirewallHelper

A class library to manage the Windows Firewall as well as adding your program to the Windows Firewall Exception list.
MIT License
274 stars 72 forks source link
firewall-configuration firewall-management firewall-profiles firewall-zones windows-firewall

Windows Firewall Helper Class Library

A class library to manage the Windows Firewall as well as adding your program to the Windows Firewall Exception list.

This project supports dotNet4.6, NetStandard2 and NetCore5, therefore, is compatible with NetCore2+ and any version of dotNet equal or greater than version 4.6.

Even though it is possible to reference this library under Linux or Mac; it's obviously not going to work.

This readme file is for the version 2 of this library. Please check the V1 branch for older readme file.

How to get

This library is available as a NuGet package at nuget.org.

Help me fund my own Death Star

--OR--

You can always donate your time by contributing to the project or by introducing it to others.

How to use

The starting point of this library is the FirewallManager static class which can be used to get the instance of the class managing the firewall currently on the system.

If you are only targeting WinVista+ consider using the FirewallWAS.Instance static property to access the library's functionality. It allows for more flexibility and is easier to work with.

WindowsFirewallHelper.FirewallManager Class

This static class contains properties about the currently active Windows Firewall management class instance or the registered third party firewall products. This class also provides methods to register a third-party firewall product.

WindowsFirewallHelper.FirewallManager Static Properties

WindowsFirewallHelper.FirewallManager Static Methods

WindowsFirewallHelper Namespace

This namespace contains shared and general classes as well as the main starting point of this library, FirewallManager class.

WindowsFirewallHelper Classes

WindowsFirewallHelper Interfaces

WindowsFirewallHelper.FirewallRules Namespace

This namespace contains classes that can be used for direct manipulation of a firewall rule.

WindowsFirewallHelper.FirewallRules Classes

WindowsFirewallHelper.Exceptions Namespace

This namespace contains exception classes that might be thrown when using this library

WindowsFirewallHelper.Exceptions Classes

WindowsFirewallHelper.Addresses Namespace

This namespace contains the classes needed for manipulating or understanding a network address or a network service.

WindowsFirewallHelper.Addresses Classes

WindowsFirewallHelper.COMInterop Namespace

This namespace contains the interfaces and enums that is used to access the underlying COM objects. Some of these types are public and can be used to directly modify a COM object. Usually firewall rules. Rest of types are internal to this library.

Examples

Check the 'WindowsFirewallHelper.Sample' and 'WindowsFirewallHelper.NetCoreSample' projects as a brief example of what can be done using this class library. Screenshot

Basic examples

Advanced examples

License

The MIT License (MIT)

Copyright (c) 2016-2020 Soroush

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.