Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit 6f54d93

Browse files
committed
#496 Dns resolve fix for external proxy
1 parent 05d0f85 commit 6f54d93

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,16 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
287287
var hostname = useUpstreamProxy ? externalProxy.HostName : remoteHostName;
288288
var port = useUpstreamProxy ? externalProxy.Port : remotePort;
289289

290-
var ipHostEntry = await Dns.GetHostEntryAsync(hostname);
290+
IPHostEntry ipHostEntry;
291+
if (IPAddress.TryParse(hostname, out var ipAddress))
292+
{
293+
ipHostEntry = await Dns.GetHostEntryAsync(ipAddress);
294+
}
295+
else
296+
{
297+
ipHostEntry = await Dns.GetHostEntryAsync(hostname);
298+
}
299+
291300
if (ipHostEntry == null || ipHostEntry.AddressList.Length == 0)
292301
{
293302
throw new Exception($"Could not resolve the hostname {hostname}");

0 commit comments

Comments
 (0)