Closed tjpeel closed 5 years ago
Thank you for your report!
I think, those behaviors of IPAddressRange
is not correct!
By the way, at first, the range text "1/2.3.4" is valid format.
Because the range text "1/2.3.4" can be parsed as "address and subnet mask" like "192.168.0.0/255.255.255.0", not as "CIDR".
The text "1" and "2.3.4" is valid IPv4 address formatted text, in the .NET world.
// C#
IPAddress.Parse("1"); // -> returns IPv4 0.0.0.1
IPAddress.Parse("2.3.4"); // -> returns IPv4 2.3.0.4
However, the format of the range text "1/2.3.4" is valid, but the IP address range of the range text "1/2.3.4" is NOT linear!
The IPAddressRange
can't treat non linear address ranges.
Therefore, I decide that the range text "1/2.3.4" has to cause FormatException
when parse it.
I fixed this problem at commit 05819a15d600455f683d8c6d7db0868d066bbbf1.
I'll publish new NuGet package of fixed this issue version.
Thanks!
Thanks, will await the updated nuget to test
Will this fix be released via nuget any time soon? Thanks
@jsakamoto thanks for pushing a new version.
What do you make of this range?
1.2.3/4
All online tools I've checked report a range error but your lib returns:
Begin 0.0.0.0 End 15.255.255.255
Many thanks
Once I said, 1.2.3
is valid IPv4 address in .NET World (it will be parsed to 1.2.0.3
IPv4 address), and .../4
describe the subnet mask that top 4 bit is bit on.
Therefore, 1.2.3/4
is valid range text for describe 0.0.0.0
~ 15.255.255.255
.
All online tools I've checked report a range error
The online tool https://mxtoolbox.com/subnetcalculator.aspx that you told me reported a valid result for query of 1.2.3/4
.
The online tool https://www.ipaddressguide.com/cidr reported error dor the query of 1.2.3/4
, however, that tool may not accept the text 1.2.3
as a valid IPv4 address, I guess.
I tried to passing the text 1.2.0.3/4
, it reported a valid result.
Of course, there is room for consideration that the combination of IPv4 address 1.2.0.3
and subnet mask 240.0.0.0
is something wrong (this combination is not overlapped in any bits).
However, those two online tools reported a valid result for the query of 1.2.0.3/4
so I think it will be no problem.
Thanks for the follow up and again for your recent fix 👍
Was looking to adopt your library and a test case that denotes an invalid range starting to fail once your library was integrated. The range is:
1/2.3.4
The following services say it's invalid:
https://www.ipaddressguide.com/cidr https://mxtoolbox.com/subnetcalculator.aspx
Do you have a view on this?
Many thanks