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

Fix Dns resolution fail when hostname is an Ip address #502

Merged
merged 2 commits into from
Oct 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
var hostname = useUpstreamProxy ? externalProxy.HostName : remoteHostName;
var port = useUpstreamProxy ? externalProxy.Port : remotePort;

var 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}");
}
Expand All @@ -298,8 +298,6 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
session.TimeLine["Dns Resolved"] = DateTime.Now;
}

var ipAddresses = ipHostEntry.AddressList;

for (int i = 0; i < ipAddresses.Length; i++)
{
try
Expand Down