-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add port range? #60
Comments
I don't think you can. we are limited by the constraints of the windows firewall here. but I will take a look. |
Windows firewall (and its FirewallAPI.dll) allows me to add "5000-7000" as string. All ports will be allowed from 5000 to 7000. But I'd like to use your library, I've already prepared my software with this, I don't want to change it. Thanks. |
I'd like to add my vote for this. In the Windows Firewall console our setting is "21, 990, 5000-5500" but this library just shows "21, 990, 5000, 5001, 5002, ..." If the API is limited to only individual ports, it would be nice if the library could group them into a range. |
So in my solution I just added an extension method to I now have
which outputs something like this: 5004-5005, 7777-7781, 50004-50013 Which is very much like Windows Firewall shows it I actually copied both public static string AsRangeString(this IFirewallRule rule) => RangeStr(Ranges(rule.LocalPorts.Select(x => Convert.ToInt32(x)).ToList())); I could have modified the original answer code to use |
There's a class in this repo called PortHelper with a method for converting port strings (including those with ranges) into an array of ports. However, the class is internal so you can't use it directly. Ideally, there would be a public method that allows setting ports for a rule using a string value, which uses |
Maybe it will help to somebody, but now you can do it like that:
|
Hello,
I want to add a port range to a rule but it allows me o add just as short/int; I need to add a port range like "5000-7000" as a string. I can't add 2000 different rules for it.
How can I handle this?
Thank you.
The text was updated successfully, but these errors were encountered: