Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
33d50f32
Commit
33d50f32
authored
May 11, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix -ive server connection count
parent
e662451f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
159 additions
and
119 deletions
+159
-119
ExplicitClientHandler.cs
Titanium.Web.Proxy/ExplicitClientHandler.cs
+4
-2
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+26
-17
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+125
-98
TransparentClientHandler.cs
Titanium.Web.Proxy/TransparentClientHandler.cs
+4
-2
No files found.
Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
33d50f32
...
...
@@ -37,6 +37,7 @@ namespace Titanium.Web.Proxy
Task
<
TcpServerConnection
>
prefetchConnectionTask
=
null
;
bool
closeServerConnection
=
false
;
bool
calledRequestHandler
=
false
;
try
{
...
...
@@ -289,7 +290,7 @@ namespace Titanium.Web.Proxy
await
tcpConnectionFactory
.
Release
(
connection
,
true
);
}
}
calledRequestHandler
=
true
;
// Now create the request
await
handleHttpSessionRequest
(
endPoint
,
clientConnection
,
clientStream
,
clientStreamWriter
,
cancellationTokenSource
,
connectHostname
,
connectArgs
?.
WebSession
.
ConnectRequest
,
prefetchConnectionTask
);
...
...
@@ -316,7 +317,8 @@ namespace Titanium.Web.Proxy
}
finally
{
if
(
prefetchConnectionTask
!=
null
)
if
(!
calledRequestHandler
&&
prefetchConnectionTask
!=
null
)
{
var
connection
=
await
prefetchConnectionTask
;
await
tcpConnectionFactory
.
Release
(
connection
,
closeServerConnection
);
...
...
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
33d50f32
...
...
@@ -42,6 +42,29 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal
ProxyServer
server
{
get
;
set
;
}
internal
string
GetConnectionCacheKey
(
string
remoteHostName
,
int
remotePort
,
Version
httpVersion
,
bool
isHttps
,
List
<
SslApplicationProtocol
>
applicationProtocols
,
bool
isConnect
,
ProxyServer
proxyServer
,
IPEndPoint
upStreamEndPoint
,
ExternalProxy
externalProxy
)
{
var
cacheKeyBuilder
=
new
StringBuilder
(
$"
{
remoteHostName
}
-
{
remotePort
}
"
+
$"-
{(
httpVersion
==
null
?
string
.
Empty
:
httpVersion
.
ToString
())}
"
+
$"-
{
isHttps
}
-
{
isConnect
}
-"
);
if
(
applicationProtocols
!=
null
)
{
foreach
(
var
protocol
in
applicationProtocols
)
{
cacheKeyBuilder
.
Append
(
$"
{
protocol
}
-"
);
}
}
cacheKeyBuilder
.
Append
(
upStreamEndPoint
!=
null
?
$"
{
upStreamEndPoint
.
Address
}
-
{
upStreamEndPoint
.
Port
}
-"
:
string
.
Empty
);
cacheKeyBuilder
.
Append
(
externalProxy
!=
null
?
$"
{
externalProxy
.
GetCacheKey
()}
-"
:
string
.
Empty
);
return
cacheKeyBuilder
.
ToString
();
}
/// <summary>
/// Gets a TCP connection to server from connection pool.
/// </summary>
...
...
@@ -61,23 +84,9 @@ namespace Titanium.Web.Proxy.Network.Tcp
ProxyServer
proxyServer
,
IPEndPoint
upStreamEndPoint
,
ExternalProxy
externalProxy
,
CancellationToken
cancellationToken
)
{
var
cacheKeyBuilder
=
new
StringBuilder
(
$"
{
remoteHostName
}
-
{
remotePort
}
"
+
$"-
{(
httpVersion
==
null
?
string
.
Empty
:
httpVersion
.
ToString
())}
"
+
$"-
{
isHttps
}
-
{
isConnect
}
-"
);
if
(
applicationProtocols
!=
null
)
{
foreach
(
var
protocol
in
applicationProtocols
)
{
cacheKeyBuilder
.
Append
(
$"
{
protocol
}
-"
);
}
}
cacheKeyBuilder
.
Append
(
upStreamEndPoint
!=
null
?
$"
{
upStreamEndPoint
.
Address
}
-
{
upStreamEndPoint
.
Port
}
-"
:
string
.
Empty
);
cacheKeyBuilder
.
Append
(
externalProxy
!=
null
?
$"
{
externalProxy
.
GetCacheKey
()}
-"
:
string
.
Empty
);
string
cacheKey
=
cacheKeyBuilder
.
ToString
();
var
cacheKey
=
GetConnectionCacheKey
(
remoteHostName
,
remotePort
,
httpVersion
,
isHttps
,
applicationProtocols
,
isConnect
,
proxyServer
,
upStreamEndPoint
,
externalProxy
);
if
(
proxyServer
.
EnableConnectionPool
)
{
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
33d50f32
This diff is collapsed.
Click to expand it.
Titanium.Web.Proxy/TransparentClientHandler.cs
View file @
33d50f32
...
...
@@ -35,6 +35,7 @@ namespace Titanium.Web.Proxy
Task
<
TcpServerConnection
>
prefetchConnectionTask
=
null
;
bool
closeServerConnection
=
false
;
bool
calledRequestHandler
=
false
;
try
{
...
...
@@ -127,7 +128,7 @@ namespace Titanium.Web.Proxy
}
}
calledRequestHandler
=
true
;
// HTTPS server created - we can now decrypt the client's traffic
// Now create the request
await
handleHttpSessionRequest
(
endPoint
,
clientConnection
,
clientStream
,
clientStreamWriter
,
...
...
@@ -155,7 +156,8 @@ namespace Titanium.Web.Proxy
}
finally
{
if
(
prefetchConnectionTask
!=
null
)
if
(!
calledRequestHandler
&&
prefetchConnectionTask
!=
null
)
{
var
connection
=
await
prefetchConnectionTask
;
await
tcpConnectionFactory
.
Release
(
connection
,
closeServerConnection
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment