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

Commit 9c034a1

Browse files
Merge pull request #502 from justcoding121/master
Fix Dns resolution fail when hostname is an Ip address
2 parents cf2a90a + 49b5fb7 commit 9c034a1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ 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);
291-
if (ipHostEntry == null || ipHostEntry.AddressList.Length == 0)
290+
var ipAddresses = await Dns.GetHostAddressesAsync(hostname);
291+
if (ipAddresses == null || ipAddresses.Length == 0)
292292
{
293293
throw new Exception($"Could not resolve the hostname {hostname}");
294294
}
@@ -298,8 +298,6 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
298298
session.TimeLine["Dns Resolved"] = DateTime.Now;
299299
}
300300

301-
var ipAddresses = ipHostEntry.AddressList;
302-
303301
for (int i = 0; i < ipAddresses.Length; i++)
304302
{
305303
try

0 commit comments

Comments
 (0)