<PackageReference Include="SSH.NET" Version="2020.0.2" />

DnsAbstraction

static class DnsAbstraction
using System; using System.Collections.Generic; using System.Net; using System.Net.Sockets; using Windows.Networking; using Windows.Networking.Sockets; namespace Renci.SshNet.Abstractions { internal static class DnsAbstraction { public static IPAddress[] GetHostAddresses(string hostNameOrAddress) { if (IPAddress.TryParse(hostNameOrAddress, out IPAddress address)) return new IPAddress[1] { address }; IReadOnlyList<EndpointPair> result = WindowsRuntimeSystemExtensions.GetAwaiter<IReadOnlyList<EndpointPair>>(DatagramSocket.GetEndpointPairsAsync(new HostName(hostNameOrAddress), "")).GetResult(); List<IPAddress> list = new List<IPAddress>(); foreach (EndpointPair item in result) { if ((int)item.get_RemoteHostName().get_Type() == 1 || (int)item.get_RemoteHostName().get_Type() == 2) list.Add(IPAddress.Parse(item.get_RemoteHostName().get_CanonicalName())); } if (list.Count == 0) throw new SocketException(11001); return list.ToArray(); } } }