Commit 48c041e6 authored by justcoding121's avatar justcoding121

#565 Verify hostname before prefetching connection

parent 10c923e3
...@@ -47,7 +47,7 @@ namespace Titanium.Web.Proxy ...@@ -47,7 +47,7 @@ namespace Titanium.Web.Proxy
{ {
string connectHostname = null; string connectHostname = null;
TunnelConnectSessionEventArgs connectArgs = null; TunnelConnectSessionEventArgs connectArgs = null;
// Client wants to create a secure tcp tunnel (probably its a HTTPS or Websocket request) // Client wants to create a secure tcp tunnel (probably its a HTTPS or Websocket request)
if (await HttpHelper.IsConnectMethod(clientStream) == 1) if (await HttpHelper.IsConnectMethod(clientStream) == 1)
...@@ -154,11 +154,17 @@ namespace Titanium.Web.Proxy ...@@ -154,11 +154,17 @@ namespace Titanium.Web.Proxy
if (EnableTcpServerConnectionPrefetch) if (EnableTcpServerConnectionPrefetch)
{ {
//don't pass cancellation token here //make sure the host can be resolved before creating the prefetch task
//it could cause floating server connections when client exits var ipAddresses = await Dns.GetHostAddressesAsync(connectArgs.HttpClient.Request.RequestUri.Host);
prefetchConnectionTask = tcpConnectionFactory.GetServerConnection(this, connectArgs,
isConnect: true, applicationProtocols: null, noCache: false, if (ipAddresses != null && ipAddresses.Length > 0)
cancellationToken: CancellationToken.None); {
//don't pass cancellation token here
//it could cause floating server connections when client exits
prefetchConnectionTask = tcpConnectionFactory.GetServerConnection(this, connectArgs,
isConnect: true, applicationProtocols: null, noCache: false,
cancellationToken: CancellationToken.None);
}
} }
X509Certificate2 certificate = null; X509Certificate2 certificate = null;
......
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