Skip to content

Commit

Permalink
refactor connection factory
Browse files Browse the repository at this point in the history
  • Loading branch information
justcoding121 committed May 16, 2018
1 parent 35b82aa commit 1a14f57
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 265 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSess

private Task OnBeforeTunnelConnectResponse(object sender, TunnelConnectSessionEventArgs e)
{
return default;
return Task.FromResult(false);
}

// intecept & cancel redirect or update requests
Expand Down
8 changes: 4 additions & 4 deletions Titanium.Web.Proxy/ExplicitClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ await clientStreamWriter.WriteResponseAsync(connectArgs.WebSession.Response,
{
// test server HTTP/2 support
// todo: this is a hack, because Titanium does not support HTTP protocol changing currently
var connection = await getServerConnection(connectArgs, true,
var connection = await tcpConnectionFactory.GetServerConnection(this, connectArgs, true,
SslExtensions.Http2ProtocolAsList, true, cancellationToken);

http2Supported = connection.NegotiatedApplicationProtocol == SslApplicationProtocol.Http2;
Expand All @@ -153,7 +153,7 @@ await clientStreamWriter.WriteResponseAsync(connectArgs.WebSession.Response,

//don't pass cancellation token here
//it could cause floating server connections when client exits
prefetchConnectionTask = getServerConnection(connectArgs, true,
prefetchConnectionTask = tcpConnectionFactory.GetServerConnection(this, connectArgs, true,
null, false, CancellationToken.None);

try
Expand Down Expand Up @@ -214,7 +214,7 @@ await clientStreamWriter.WriteResponseAsync(connectArgs.WebSession.Response,
// create new connection to server.
// If we detected that client tunnel CONNECTs without SSL by checking for empty client hello then
// this connection should not be HTTPS.
var connection = await getServerConnection(connectArgs,
var connection = await tcpConnectionFactory.GetServerConnection(this, connectArgs,
true, SslExtensions.Http2ProtocolAsList, true, cancellationToken);

try
Expand Down Expand Up @@ -284,7 +284,7 @@ await TcpHelper.SendRaw(clientStream, connection.Stream, BufferPool, BufferSize,
throw new Exception($"HTTP/2 Protocol violation. Empty string expected, '{line}' received");
}

var connection = await getServerConnection(connectArgs, true,
var connection = await tcpConnectionFactory.GetServerConnection(this, connectArgs, true,
SslExtensions.Http2ProtocolAsList, true,
cancellationToken);
try
Expand Down
Loading

0 comments on commit 1a14f57

Please sign in to comment.