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
b3499602
Commit
b3499602
authored
May 08, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update logic to reflect time out change in factory
parent
36249467
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
19 deletions
+23
-19
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+22
-18
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+1
-1
No files found.
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
b3499602
...
...
@@ -33,9 +33,12 @@ namespace Titanium.Web.Proxy.Network.Tcp
//cache object race operations lock
private
readonly
SemaphoreSlim
@lock
=
new
SemaphoreSlim
(
1
);
internal
TcpConnectionFactory
(
int
connectionTimeOutSeconds
)
internal
ProxyServer
server
{
get
;
set
;
}
internal
TcpConnectionFactory
(
ProxyServer
server
)
{
Task
.
Run
(
async
()
=>
await
ClearOutdatedConnections
(
connectionTimeOutSeconds
));
this
.
server
=
server
;
Task
.
Run
(
async
()
=>
await
ClearOutdatedConnections
());
}
/// <summary>
...
...
@@ -58,8 +61,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
CancellationToken
cancellationToken
)
{
string
cacheKey
=
null
;
if
(
proxyServer
.
EnableConnectionPool
)
{
var
cacheKeyBuilder
=
new
StringBuilder
(
$"
{
remoteHostName
}
-
{
remotePort
}
"
+
$"-
{(
httpVersion
==
null
?
string
.
Empty
:
httpVersion
.
ToString
())}
"
+
$"-
{
isHttps
}
-
{
isConnect
}
-"
);
...
...
@@ -78,6 +80,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
cacheKey
=
cacheKeyBuilder
.
ToString
();
if
(
proxyServer
.
EnableConnectionPool
)
{
if
(
cache
.
TryGetValue
(
cacheKey
,
out
var
existingConnections
))
{
while
(
existingConnections
.
TryDequeue
(
out
var
recentConnection
))
...
...
@@ -278,7 +282,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
@lock
.
Release
();
}
private
async
Task
ClearOutdatedConnections
(
int
connectionTimeOutSeconds
)
private
async
Task
ClearOutdatedConnections
()
{
while
(
true
)
...
...
@@ -288,7 +292,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
var
queue
=
item
.
Value
;
while
(
queue
.
TryDequeue
(
out
var
connection
))
{
var
cutOff
=
DateTime
.
Now
.
AddSeconds
(-
1
*
c
onnectionTimeOutSeconds
);
var
cutOff
=
DateTime
.
Now
.
AddSeconds
(-
1
*
server
.
C
onnectionTimeOutSeconds
);
if
(
connection
.
LastAccess
<
cutOff
)
{
disposalBag
.
Add
(
connection
);
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
b3499602
...
...
@@ -98,7 +98,7 @@ namespace Titanium.Web.Proxy
ConnectionTimeOutSeconds
=
60
;
ProxyEndPoints
=
new
List
<
ProxyEndPoint
>();
tcpConnectionFactory
=
new
TcpConnectionFactory
(
ConnectionTimeOutSecond
s
);
tcpConnectionFactory
=
new
TcpConnectionFactory
(
thi
s
);
if
(!
RunTime
.
IsRunningOnMono
&&
RunTime
.
IsWindows
)
{
systemProxySettingsManager
=
new
SystemProxyManager
();
...
...
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