Commit 6f54d939 authored by justcoding121's avatar justcoding121

#496 Dns resolve fix for external proxy

parent 05d0f85e
...@@ -287,7 +287,16 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -287,7 +287,16 @@ namespace Titanium.Web.Proxy.Network.Tcp
var hostname = useUpstreamProxy ? externalProxy.HostName : remoteHostName; var hostname = useUpstreamProxy ? externalProxy.HostName : remoteHostName;
var port = useUpstreamProxy ? externalProxy.Port : remotePort; var port = useUpstreamProxy ? externalProxy.Port : remotePort;
var ipHostEntry = await Dns.GetHostEntryAsync(hostname); 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) if (ipHostEntry == null || ipHostEntry.AddressList.Length == 0)
{ {
throw new Exception($"Could not resolve the hostname {hostname}"); throw new Exception($"Could not resolve the hostname {hostname}");
......
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