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
ebc25f50
Commit
ebc25f50
authored
Sep 22, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optional prefetch
parent
b6bdf046
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
21 deletions
+36
-21
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+0
-1
ExplicitClientHandler.cs
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
+10
-7
ProxyServer.cs
src/Titanium.Web.Proxy/ProxyServer.cs
+16
-6
TransparentClientHandler.cs
src/Titanium.Web.Proxy/TransparentClientHandler.cs
+10
-7
No files found.
examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
ebc25f50
...
...
@@ -24,7 +24,6 @@ namespace Titanium.Web.Proxy.Examples.Basic
public
ProxyTestController
()
{
proxyServer
=
new
ProxyServer
();
proxyServer
.
EnableConnectionPool
=
true
;
// generate root certificate without storing it in file system
//proxyServer.CertificateManager.CreateRootCertificate(false);
...
...
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
ebc25f50
...
...
@@ -152,11 +152,14 @@ namespace Titanium.Web.Proxy
SslStream
sslStream
=
null
;
//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
);
if
(
EnableTcpServerConnectionPrefetch
)
{
//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
);
}
try
{
...
...
@@ -204,10 +207,10 @@ namespace Titanium.Web.Proxy
decryptSsl
=
false
;
}
if
(!
decryptSsl
)
if
(!
decryptSsl
)
{
await
tcpConnectionFactory
.
Release
(
prefetchConnectionTask
,
true
);
prefetchConnectionTask
=
null
;
prefetchConnectionTask
=
null
;
}
}
...
...
src/Titanium.Web.Proxy/ProxyServer.cs
View file @
ebc25f50
...
...
@@ -161,9 +161,19 @@ namespace Titanium.Web.Proxy
/// <summary>
/// Should we enable experimental server connection pool?
/// Defaults to
disabl
e.
/// Defaults to
tru
e.
/// </summary>
public
bool
EnableConnectionPool
{
get
;
set
;
}
public
bool
EnableConnectionPool
{
get
;
set
;
}
=
true
;
/// <summary>
/// Should we enable tcp server connection prefetching?
/// When enabled, as soon as we receive a client connection we concurrently initiate
/// corresponding server connection process using CONNECT hostname or SNI hostname on a separate task so that after parsing client request
/// we will have the server connection immediately ready or in the process of getting ready.
/// If a server connection is available in cache then this prefetch task will immediatly return with the available connection from cache.
/// Defaults to true.
/// </summary>
public
bool
EnableTcpServerConnectionPrefetch
{
get
;
set
;
}
=
true
;
/// <summary>
/// Buffer size in bytes used throughout this proxy.
...
...
@@ -186,14 +196,14 @@ namespace Titanium.Web.Proxy
public
int
MaxCachedConnections
{
get
;
set
;
}
=
2
;
/// <summary>
/// Number of seconds to linger when Tcp connection is in TIME_WAIT state.
/// Default value is 30.
///
Number of seconds to linger when Tcp connection is in TIME_WAIT state.
///
Default value is 30.
/// </summary>
public
int
TcpTimeWaitSeconds
{
get
;
set
;
}
=
30
;
/// <summary>
/// Should we reuse client/server tcp sockets.
/// Default is true (disabled for linux/macOS due to bug in .Net core).
///
Should we reuse client/server tcp sockets.
///
Default is true (disabled for linux/macOS due to bug in .Net core).
/// </summary>
public
bool
ReuseSocket
{
get
;
set
;
}
=
true
;
...
...
src/Titanium.Web.Proxy/TransparentClientHandler.cs
View file @
ebc25f50
...
...
@@ -63,13 +63,16 @@ namespace Titanium.Web.Proxy
if
(
endPoint
.
DecryptSsl
&&
args
.
DecryptSsl
)
{
//don't pass cancellation token here
//it could cause floating server connections when client exits
prefetchConnectionTask
=
tcpConnectionFactory
.
GetServerConnection
(
httpsHostName
,
endPoint
.
Port
,
httpVersion
:
null
,
isHttps
:
true
,
applicationProtocols
:
null
,
isConnect
:
false
,
proxyServer
:
this
,
upStreamEndPoint
:
UpStreamEndPoint
,
externalProxy
:
UpStreamHttpsProxy
,
noCache
:
false
,
cancellationToken
:
CancellationToken
.
None
);
if
(
EnableTcpServerConnectionPrefetch
)
{
//don't pass cancellation token here
//it could cause floating server connections when client exits
prefetchConnectionTask
=
tcpConnectionFactory
.
GetServerConnection
(
httpsHostName
,
endPoint
.
Port
,
httpVersion
:
null
,
isHttps
:
true
,
applicationProtocols
:
null
,
isConnect
:
false
,
proxyServer
:
this
,
upStreamEndPoint
:
UpStreamEndPoint
,
externalProxy
:
UpStreamHttpsProxy
,
noCache
:
false
,
cancellationToken
:
CancellationToken
.
None
);
}
SslStream
sslStream
=
null
;
//do client authentication using fake certificate
...
...
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