Commit 49b5fb77 authored by justcoding121's avatar justcoding121

use GetHostAddressesAsync

parent 6f54d939
......@@ -287,17 +287,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
var hostname = useUpstreamProxy ? externalProxy.HostName : remoteHostName;
var port = useUpstreamProxy ? externalProxy.Port : remotePort;
IPHostEntry ipHostEntry;
if (IPAddress.TryParse(hostname, out var ipAddress))
{
ipHostEntry = await Dns.GetHostEntryAsync(ipAddress);
}
else
{
ipHostEntry = await Dns.GetHostEntryAsync(hostname);
}
if (ipHostEntry == null || ipHostEntry.AddressList.Length == 0)
var ipAddresses = await Dns.GetHostAddressesAsync(hostname);
if (ipAddresses == null || ipAddresses.Length == 0)
{
throw new Exception($"Could not resolve the hostname {hostname}");
}
......@@ -307,8 +298,6 @@ namespace Titanium.Web.Proxy.Network.Tcp
session.TimeLine["Dns Resolved"] = DateTime.Now;
}
var ipAddresses = ipHostEntry.AddressList;
for (int i = 0; i < ipAddresses.Length; i++)
{
try
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment