falahati / WindowsFirewallHelper

A class library to manage the Windows Firewall as well as adding your program to the Windows Firewall Exception list.
MIT License
276 stars 72 forks source link

Issue setting RemoteAddresses of a FirewallRule with a range of IPv6 addresses #47

Open nmehtaMS opened 3 years ago

nmehtaMS commented 3 years ago

For the following code

rule.RemoteAddresses = remoteAddresses;

when assigning an array of remoteAddresses which includes an IPv6 address range eg 1234:1030:20e:3::6f/127 start IP 1234:1030:20e:3::6e last IP 1234:1030:20e:3::6f

it fails to set the remoteAddresses property and throws an exception

Exception Stack Trace " at WindowsFirewallHelper.COMInterop.INetFwRule.set_RemoteAddresses(String value)\r\n at WindowsFirewallHelper.FirewallRules.FirewallWASRule.set_RemoteAddresses(IAddress[] value) in C:\Users\s_fal\Documents\Personal\Open-Source Projects\WindowsFirewallHelper\WindowsFirewallHelper\FirewallRules\FirewallWASRule.cs:line 584\r\n at FirewallService.CreateFirewallRule(String name, FirewallAction action, FirewallDirection direction, FirewallProtocol protocol, UInt16[] destinationPortsList, IAddress[] remoteAddresses, IAddress[] localAddresses) in ...

This works fine when the IPv6 CIDR is /128 eg 1234:1030:20e:3::6f/128

Images for context

MicrosoftTeams-image MicrosoftTeams-image (1)