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
17a1aabe
Unverified
Commit
17a1aabe
authored
May 14, 2018
by
justcoding121
Committed by
GitHub
May 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #444 from justcoding121/master
connection pool improvements
parents
45b13d34
c9c47fab
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
83 deletions
+102
-83
ExplicitClientHandler.cs
Titanium.Web.Proxy/ExplicitClientHandler.cs
+39
-29
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+11
-20
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+13
-6
TransparentClientHandler.cs
Titanium.Web.Proxy/TransparentClientHandler.cs
+25
-21
Titanium.Web.Proxy.ProxyServer.html
docs/api/Titanium.Web.Proxy.ProxyServer.html
+13
-6
index.json
docs/index.json
+1
-1
No files found.
Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
17a1aabe
...
...
@@ -212,6 +212,8 @@ namespace Titanium.Web.Proxy
var
connection
=
await
getServerConnection
(
connectArgs
,
true
,
null
,
cancellationToken
);
try
{
if
(
isClientHello
)
{
int
available
=
clientStream
.
Available
;
...
...
@@ -242,8 +244,11 @@ namespace Titanium.Web.Proxy
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataSent
(
buffer
,
offset
,
count
);
},
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataReceived
(
buffer
,
offset
,
count
);
},
connectArgs
.
CancellationTokenSource
,
ExceptionFunc
);
}
finally
{
await
tcpConnectionFactory
.
Release
(
connection
,
true
);
}
return
;
}
}
...
...
@@ -276,7 +281,8 @@ namespace Titanium.Web.Proxy
// create new connection
var
connection
=
await
getServerConnection
(
connectArgs
,
true
,
SslExtensions
.
Http2ProtocolAsList
,
cancellationToken
);
try
{
await
connection
.
StreamWriter
.
WriteLineAsync
(
"PRI * HTTP/2.0"
,
cancellationToken
);
await
connection
.
StreamWriter
.
WriteLineAsync
(
cancellationToken
);
await
connection
.
StreamWriter
.
WriteLineAsync
(
"SM"
,
cancellationToken
);
...
...
@@ -288,9 +294,13 @@ namespace Titanium.Web.Proxy
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataReceived
(
buffer
,
offset
,
count
);
},
connectArgs
.
CancellationTokenSource
,
clientConnection
.
Id
,
ExceptionFunc
);
#endif
}
finally
{
await
tcpConnectionFactory
.
Release
(
connection
,
true
);
}
}
}
calledRequestHandler
=
true
;
// Now create the request
await
handleHttpSessionRequest
(
endPoint
,
clientConnection
,
clientStream
,
clientStreamWriter
,
...
...
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
17a1aabe
...
...
@@ -94,10 +94,6 @@ namespace Titanium.Web.Proxy.Network.Tcp
if
(
proxyServer
.
EnableConnectionPool
)
{
try
{
await
@lock
.
WaitAsync
();
if
(
cache
.
TryGetValue
(
cacheKey
,
out
var
existingConnections
))
{
while
(
existingConnections
.
Count
>
0
)
...
...
@@ -118,11 +114,6 @@ namespace Titanium.Web.Proxy.Network.Tcp
}
}
}
finally
{
@lock
.
Release
();
}
}
var
connection
=
await
createClient
(
remoteHostName
,
remotePort
,
httpVersion
,
isHttps
,
applicationProtocols
,
isConnect
,
proxyServer
,
upStreamEndPoint
,
externalProxy
,
cancellationToken
);
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
17a1aabe
...
...
@@ -130,6 +130,7 @@ namespace Titanium.Web.Proxy
/// <summary>
/// Gets or sets a value indicating whether requests will be chained to upstream gateway.
/// Defaults to false.
/// </summary>
public
bool
ForwardToUpstreamGateway
{
get
;
set
;
}
...
...
@@ -138,6 +139,7 @@ namespace Titanium.Web.Proxy
/// Note: NTLM/Kerberos will always send local credentials of current user
/// running the proxy process. This is because a man
/// in middle attack with Windows domain authentication is not currently supported.
/// Defaults to false.
/// </summary>
public
bool
EnableWinAuth
{
get
;
set
;
}
...
...
@@ -155,18 +157,21 @@ namespace Titanium.Web.Proxy
public
bool
Enable100ContinueBehaviour
{
get
;
set
;
}
/// <summary>
/// Should we enable server connection pool?
/// Defaults to
tru
e.
/// Should we enable
experimental
server connection pool?
/// Defaults to
disabl
e.
/// </summary>
public
bool
EnableConnectionPool
{
get
;
set
;
}
=
true
;
public
bool
EnableConnectionPool
{
get
;
set
;
}
/// <summary>
/// Buffer size used throughout this proxy.
/// Buffer size in bytes used throughout this proxy.
/// Default value is 8192 bytes.
/// </summary>
public
int
BufferSize
{
get
;
set
;
}
=
8192
;
/// <summary>
/// Seconds client/server connection are to be kept alive when waiting for read/write to complete.
/// This will also determine the pool eviction time when connection pool is enabled.
/// Default value is 60 seconds.
/// </summary>
public
int
ConnectionTimeOutSeconds
{
get
;
set
;
}
...
...
@@ -174,9 +179,9 @@ namespace Titanium.Web.Proxy
/// <summary>
/// Maximum number of concurrent connections per remote host in cache.
/// Only valid when connection pooling is enabled.
/// Default value is
3
.
/// Default value is
2
.
/// </summary>
public
int
MaxCachedConnections
{
get
;
set
;
}
=
3
;
public
int
MaxCachedConnections
{
get
;
set
;
}
=
2
;
/// <summary>
/// Total number of active client connections.
...
...
@@ -204,6 +209,8 @@ namespace Titanium.Web.Proxy
/// <summary>
/// The buffer pool used throughout this proxy instance.
/// Set custom implementations by implementing this interface.
/// By default this uses DefaultBufferPool implementation available in StreamExtended library package.
/// </summary>
public
IBufferPool
BufferPool
{
get
;
set
;
}
...
...
Titanium.Web.Proxy/TransparentClientHandler.cs
View file @
17a1aabe
...
...
@@ -98,7 +98,8 @@ namespace Titanium.Web.Proxy
null
,
false
,
null
,
true
,
this
,
UpStreamEndPoint
,
UpStreamHttpsProxy
,
cancellationToken
);
try
{
var
serverStream
=
connection
.
Stream
;
int
available
=
clientStream
.
Available
;
...
...
@@ -122,10 +123,13 @@ namespace Titanium.Web.Proxy
await
TcpHelper
.
SendRaw
(
clientStream
,
serverStream
,
BufferPool
,
BufferSize
,
null
,
null
,
cancellationTokenSource
,
ExceptionFunc
);
}
finally
{
await
tcpConnectionFactory
.
Release
(
connection
,
true
);
return
;
}
return
;
}
}
calledRequestHandler
=
true
;
...
...
docs/api/Titanium.Web.Proxy.ProxyServer.html
View file @
17a1aabe
...
...
@@ -260,7 +260,9 @@ Should return true for successful authentication.</p>
<a
id=
"Titanium_Web_Proxy_ProxyServer_BufferPool_"
data-uid=
"Titanium.Web.Proxy.ProxyServer.BufferPool*"
></a>
<h4
id=
"Titanium_Web_Proxy_ProxyServer_BufferPool"
data-uid=
"Titanium.Web.Proxy.ProxyServer.BufferPool"
>
BufferPool
</h4>
<div
class=
"markdown level1 summary"
><p>
The buffer pool used throughout this proxy instance.
</p>
<div
class=
"markdown level1 summary"
><p>
The buffer pool used throughout this proxy instance.
Set custom implementations by implementing this interface.
By default this uses DefaultBufferPool implementation available in StreamExtended library package.
</p>
</div>
<div
class=
"markdown level1 conceptual"
></div>
<h5
class=
"decalaration"
>
Declaration
</h5>
...
...
@@ -286,7 +288,8 @@ Should return true for successful authentication.</p>
<a
id=
"Titanium_Web_Proxy_ProxyServer_BufferSize_"
data-uid=
"Titanium.Web.Proxy.ProxyServer.BufferSize*"
></a>
<h4
id=
"Titanium_Web_Proxy_ProxyServer_BufferSize"
data-uid=
"Titanium.Web.Proxy.ProxyServer.BufferSize"
>
BufferSize
</h4>
<div
class=
"markdown level1 summary"
><p>
Buffer size used throughout this proxy.
</p>
<div
class=
"markdown level1 summary"
><p>
Buffer size in bytes used throughout this proxy.
Default value is 8192 bytes.
</p>
</div>
<div
class=
"markdown level1 conceptual"
></div>
<h5
class=
"decalaration"
>
Declaration
</h5>
...
...
@@ -391,7 +394,9 @@ Note: If enabled can reduce performance. Defaults to false.</p>
<a
id=
"Titanium_Web_Proxy_ProxyServer_ConnectionTimeOutSeconds_"
data-uid=
"Titanium.Web.Proxy.ProxyServer.ConnectionTimeOutSeconds*"
></a>
<h4
id=
"Titanium_Web_Proxy_ProxyServer_ConnectionTimeOutSeconds"
data-uid=
"Titanium.Web.Proxy.ProxyServer.ConnectionTimeOutSeconds"
>
ConnectionTimeOutSeconds
</h4>
<div
class=
"markdown level1 summary"
><p>
Seconds client/server connection are to be kept alive when waiting for read/write to complete.
</p>
<div
class=
"markdown level1 summary"
><p>
Seconds client/server connection are to be kept alive when waiting for read/write to complete.
This will also determine the pool eviction time when connection pool is enabled.
Default value is 60 seconds.
</p>
</div>
<div
class=
"markdown level1 conceptual"
></div>
<h5
class=
"decalaration"
>
Declaration
</h5>
...
...
@@ -475,7 +480,8 @@ Defaults to true.</p>
<div
class=
"markdown level1 summary"
><p>
Enable disable Windows Authentication (NTLM/Kerberos).
Note: NTLM/Kerberos will always send local credentials of current user
running the proxy process. This is because a man
in middle attack with Windows domain authentication is not currently supported.
</p>
in middle attack with Windows domain authentication is not currently supported.
Defaults to false.
</p>
</div>
<div
class=
"markdown level1 conceptual"
></div>
<h5
class=
"decalaration"
>
Declaration
</h5>
...
...
@@ -527,7 +533,8 @@ in middle attack with Windows domain authentication is not currently supported.<
<a
id=
"Titanium_Web_Proxy_ProxyServer_ForwardToUpstreamGateway_"
data-uid=
"Titanium.Web.Proxy.ProxyServer.ForwardToUpstreamGateway*"
></a>
<h4
id=
"Titanium_Web_Proxy_ProxyServer_ForwardToUpstreamGateway"
data-uid=
"Titanium.Web.Proxy.ProxyServer.ForwardToUpstreamGateway"
>
ForwardToUpstreamGateway
</h4>
<div
class=
"markdown level1 summary"
><p>
Gets or sets a value indicating whether requests will be chained to upstream gateway.
</p>
<div
class=
"markdown level1 summary"
><p>
Gets or sets a value indicating whether requests will be chained to upstream gateway.
Defaults to false.
</p>
</div>
<div
class=
"markdown level1 conceptual"
></div>
<h5
class=
"decalaration"
>
Declaration
</h5>
...
...
@@ -582,7 +589,7 @@ User should return the ExternalProxy object with valid credentials.</p>
<h4
id=
"Titanium_Web_Proxy_ProxyServer_MaxCachedConnections"
data-uid=
"Titanium.Web.Proxy.ProxyServer.MaxCachedConnections"
>
MaxCachedConnections
</h4>
<div
class=
"markdown level1 summary"
><p>
Maximum number of concurrent connections per remote host in cache.
Only valid when connection pooling is enabled.
Default value is
3
.
</p>
Default value is
2
.
</p>
</div>
<div
class=
"markdown level1 conceptual"
></div>
<h5
class=
"decalaration"
>
Declaration
</h5>
...
...
docs/index.json
View file @
17a1aabe
This diff is collapsed.
Click to expand it.
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