diff --git a/src/IPAddressExtensions.cs b/src/IPAddressExtensions.cs deleted file mode 100644 index d9a6099..0000000 --- a/src/IPAddressExtensions.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Linq; -using System.Net; -using System.Net.Sockets; -using System.Text; - -namespace Makaretu.Dns -{ - /// - /// Extension methods for . - /// - /// - /// Original code copied from - /// - public static class IPAddressExtensions - { - /// - /// Translates a IPv4 or IPv6 address into an arpa address. - /// Used for reverse DNS lookup to get the domain name of the given address. - /// - /// The address to translate. - /// The arpa representation of the address. - /// - public static string GetArpaName(this IPAddress ip) - { - var bytes = ip.GetAddressBytes(); - Array.Reverse(bytes); - - // check IP6 - if (ip.AddressFamily == AddressFamily.InterNetworkV6) - { - // reveresed bytes need to be split into 4 bit parts and separated by '.' - var newBytes = bytes - .SelectMany(b => new[] { (b >> 0) & 0xf, (b >> 4) & 0xf }) - .Aggregate(new StringBuilder(), (s, b) => s.Append(b.ToString("x")).Append(".")) + "ip6.arpa"; - - return newBytes; - } - else if (ip.AddressFamily == AddressFamily.InterNetwork) - { - // else IP4 - return string.Join(".", bytes) + ".in-addr.arpa"; - } - - // never happens anyways!? - throw new ArgumentException($"Unsupported address family '{ip.AddressFamily}'.", nameof(ip)); - } - } -} \ No newline at end of file diff --git a/src/Udns.csproj b/src/Udns.csproj index c653996..0fbf028 100644 --- a/src/Udns.csproj +++ b/src/Udns.csproj @@ -31,7 +31,7 @@ - + diff --git a/test/IPAddressExtensionsTest.cs b/test/IPAddressExtensionsTest.cs deleted file mode 100644 index e244cc0..0000000 --- a/test/IPAddressExtensionsTest.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Makaretu.Dns; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.NetworkInformation; -using System.Net.Sockets; -using System.Threading; -using System.Threading.Tasks; - -namespace Makaretu.Dns -{ - - [TestClass] - public class IPAddressExtensionsTest - { - [TestMethod] - public void ArpaName() - { - Assert.AreEqual("4.4.8.8.in-addr.arpa", IPAddress.Parse("8.8.4.4").GetArpaName()); - Assert.AreEqual("b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", IPAddress.Parse("2001:db8::567:89ab").GetArpaName()); - } - - } -}