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

Problem creating ICMP rules [Help Wanted] (again!) #52

Closed sscotter closed 2 years ago

sscotter commented 2 years ago

Hi,

Today I've updated a legacy project from v1.4.6592.8627 to v2.1.4.81

Most of my code continues to work, but I'm unable to suss how to create a rule to allow ICMP.

Back in 2019 in issue #12 you helped me and gave me the following example.

Dim Rule = New WindowsFirewallHelper.FirewallAPIv2.Rules.StandardRule("NAME2", FirewallAction.Allow, FirewallDirection.Inbound, FirewallProfiles.Domain)
Rule.Protocol = FirewallProtocol.ICMPv4
Rule.RemoteAddresses = {WindowsFirewallHelper.Addresses.SingleIP.Parse("192.168.0.1")}
FirewallManager.Instance.Rules.Add(Rule)

I've been unable to find how to replicate this functionality in v2 of your library. I'd be most grateful if you could assist me!

Cheers

Steve

falahati commented 2 years ago

The same code should work, you only need to replace WindowsFirewallHelper.FirewallAPIv2.Rules.StandardRule with WindowsFirewallHelper.FirewallRules.FirewallWASRule.

If you are getting an exception after doing so, please report here so that I look deeper into it.

sscotter commented 2 years ago

That worked perfectly, thank you!

Dim Rule = New WindowsFirewallHelper.FirewallRules.FirewallWASRule("NAME2", FirewallAction.Allow, FirewallDirection.Inbound, FirewallProfiles.Domain)
Rule.Protocol = FirewallProtocol.ICMPv4
Rule.RemoteAddresses = {WindowsFirewallHelper.Addresses.SingleIP.Parse("192.168.0.1")}
FirewallManager.Instance.Rules.Add(Rule)