Skip to content

Wrong range Assumption #5

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions WhoisClient.NET.Test.Core20/IpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class IpTests
[InlineData(@"4.4.4.4", @"Level 3 Communications, Inc. LVLT-STATIC-4-4-16 (NET-4-4-0-0-1)", @"4.4.0.0-4.4.255.255")]
[InlineData(@"65.100.170.169", @"Alana Scheffield USW-FFCF (NET-65-100-170-168-1)", @"65.100.170.168-65.100.170.175")]
[InlineData(@"108.234.177.20", @"AT&T Corp.", @"108.192.0.0-108.255.255.255")]
[InlineData(@"190.190.132.64", @"Telecom Argentina S.A.", @"190.0.0.0-190.1.255.255")]
[InlineData(@"190.190.132.64", @"Telecom Argentina S.A.", @"190.190.0.0-190.191.255.255")]
[InlineData(@"31.116.94.96", @"EE route", @"31.64.0.0-31.127.255.255")]
public void WhoisClientTest(string ip, string expectedOrgName, string expectedAddressRange)
{
Expand All @@ -23,7 +23,7 @@ public void WhoisClientTest(string ip, string expectedOrgName, string expectedAd
[InlineData(@"4.4.4.4", @"Level 3 Communications, Inc. LVLT-STATIC-4-4-16 (NET-4-4-0-0-1)", @"4.4.0.0-4.4.255.255")]
[InlineData(@"65.100.170.169", @"Alana Scheffield USW-FFCF (NET-65-100-170-168-1)", @"65.100.170.168-65.100.170.175")]
[InlineData(@"108.234.177.20", @"AT&T Corp.", @"108.192.0.0-108.255.255.255")]
[InlineData(@"190.190.132.64", @"Telecom Argentina S.A.", @"190.0.0.0-190.1.255.255")]
[InlineData(@"190.190.132.64", @"Telecom Argentina S.A.", @"190.190.0.0-190.191.255.255")]
[InlineData(@"31.116.94.96", @"EE route", @"31.64.0.0-31.127.255.255")]
public async Task WhoisClientAsyncTest(string ip, string expectedOrgName, string expectedAddressRange)
{
Expand Down
12 changes: 11 additions & 1 deletion WhoisClient.NET/WhoisResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,17 @@ public WhoisResponse(string[] responsedServers, string rawWhoisResponse)
RegexOptions.Multiline);
if (m2.Success)
{
this.AddressRange = IPAddressRange.Parse(m2.Groups["adr"].Value);
var adr = m2.Groups["adr"].Value;
if (adr.Count(c => c == '.') < 3 && adr.Contains('/'))
{
var arrAdr = adr.Split('/');
var ip = arrAdr[0];
var suffix = arrAdr[1];
for (var i = 3; i > adr.Count(c => c == '.'); i--)
ip += ".0";
adr = $"{ip}/{suffix}";
}
this.AddressRange = IPAddressRange.Parse(adr);
}

// resolve ARIN Address Range.
Expand Down