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
6eb3a4f9
Commit
6eb3a4f9
authored
May 10, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update package
parent
adcd51fc
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
55 additions
and
37 deletions
+55
-37
Titanium.Web.Proxy.Examples.Wpf.csproj
...Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj
+2
-2
packages.config
Examples/Titanium.Web.Proxy.Examples.Wpf/packages.config
+1
-1
ExplicitClientHandler.cs
Titanium.Web.Proxy/ExplicitClientHandler.cs
+3
-3
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+39
-22
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+2
-1
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+3
-3
ResponseHandler.cs
Titanium.Web.Proxy/ResponseHandler.cs
+1
-1
Titanium.Web.Proxy.csproj
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+1
-1
Titanium.Web.Proxy.nuspec
Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
+1
-1
TransparentClientHandler.cs
Titanium.Web.Proxy/TransparentClientHandler.cs
+1
-1
packages.config
Titanium.Web.Proxy/packages.config
+1
-1
No files found.
Examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj
View file @
6eb3a4f9
...
...
@@ -51,8 +51,8 @@
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"StreamExtended, Version=1.0.17
0
.0, Culture=neutral, PublicKeyToken=bbfa0f1d54f50043, processorArchitecture=MSIL"
>
<HintPath>
..\..\packages\StreamExtended.1.0.17
0
-beta\lib\net45\StreamExtended.dll
</HintPath>
<Reference
Include=
"StreamExtended, Version=1.0.17
5
.0, Culture=neutral, PublicKeyToken=bbfa0f1d54f50043, processorArchitecture=MSIL"
>
<HintPath>
..\..\packages\StreamExtended.1.0.17
5
-beta\lib\net45\StreamExtended.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Data"
/>
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/packages.config
View file @
6eb3a4f9
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"StreamExtended"
version
=
"1.0.17
0
-beta"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.17
5
-beta"
targetFramework
=
"net45"
/>
</
packages
>
\ No newline at end of file
Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
6eb3a4f9
...
...
@@ -143,7 +143,7 @@ namespace Titanium.Web.Proxy
//release connection back to pool intead of closing when connection pool is enabled
//In future we can connect to server preemptively here for all HTTPS connections using connect hostname
//and then release it back to pool so that we can save time when reading client headers
tcpConnectionFactory
.
Release
(
connection
,
!
EnableConnectionPool
);
await
tcpConnectionFactory
.
Release
(
connection
,
!
EnableConnectionPool
);
}
SslStream
sslStream
=
null
;
...
...
@@ -238,7 +238,7 @@ namespace Titanium.Web.Proxy
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataReceived
(
buffer
,
offset
,
count
);
},
connectArgs
.
CancellationTokenSource
,
ExceptionFunc
);
tcpConnectionFactory
.
Release
(
connection
,
true
);
await
tcpConnectionFactory
.
Release
(
connection
,
true
);
return
;
}
}
...
...
@@ -283,7 +283,7 @@ namespace Titanium.Web.Proxy
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDataReceived
(
buffer
,
offset
,
count
);
},
connectArgs
.
CancellationTokenSource
,
clientConnection
.
Id
,
ExceptionFunc
);
#endif
tcpConnectionFactory
.
Release
(
connection
,
true
);
await
tcpConnectionFactory
.
Release
(
connection
,
true
);
}
}
...
...
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
6eb3a4f9
...
...
@@ -32,7 +32,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
//cache object race operations lock
private
readonly
SemaphoreSlim
@lock
=
new
SemaphoreSlim
(
1
);
private
bool
runCleanUpTask
=
true
;
private
volatile
bool
runCleanUpTask
=
true
;
internal
TcpConnectionFactory
(
ProxyServer
server
)
{
...
...
@@ -112,7 +112,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// </summary>
/// <param name="connection">The Tcp server connection to return.</param>
/// <param name="close">Should we just close the connection instead of reusing?</param>
internal
void
Release
(
TcpServerConnection
connection
,
bool
close
=
false
)
internal
async
Task
Release
(
TcpServerConnection
connection
,
bool
close
=
false
)
{
if
(
close
||
connection
.
IsWinAuthenticated
)
{
...
...
@@ -122,7 +122,10 @@ namespace Titanium.Web.Proxy.Network.Tcp
connection
.
LastAccess
=
DateTime
.
Now
;
@lock
.
Wait
();
try
{
await
@lock
.
WaitAsync
();
while
(
true
)
{
if
(
cache
.
TryGetValue
(
connection
.
CacheKey
,
out
var
existingConnections
))
...
...
@@ -134,17 +137,24 @@ namespace Titanium.Web.Proxy.Network.Tcp
disposalBag
.
Add
(
staleConnection
);
}
}
existingConnections
.
Enqueue
(
connection
);
break
;
}
if
(
cache
.
TryAdd
(
connection
.
CacheKey
,
new
ConcurrentQueue
<
TcpServerConnection
>(
new
[]
{
connection
})))
if
(
cache
.
TryAdd
(
connection
.
CacheKey
,
new
ConcurrentQueue
<
TcpServerConnection
>(
new
[]
{
connection
})))
{
break
;
}
}
}
finally
{
@lock
.
Release
();
}
}
private
async
Task
clearOutdatedConnections
()
{
...
...
@@ -167,14 +177,21 @@ namespace Titanium.Web.Proxy.Network.Tcp
}
}
//clear empty queues
try
{
await
@lock
.
WaitAsync
();
//clear empty queues
var
emptyKeys
=
cache
.
Where
(
x
=>
x
.
Value
.
Count
==
0
).
Select
(
x
=>
x
.
Key
).
ToList
();
foreach
(
string
key
in
emptyKeys
)
{
cache
.
TryRemove
(
key
,
out
var
_
);
}
}
finally
{
@lock
.
Release
();
}
while
(
disposalBag
.
TryTake
(
out
var
connection
))
{
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
6eb3a4f9
...
...
@@ -269,6 +269,7 @@ namespace Titanium.Web.Proxy
}
CertificateManager
?.
Dispose
();
BufferPool
?.
Dispose
();
}
/// <summary>
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
6eb3a4f9
...
...
@@ -184,7 +184,7 @@ namespace Titanium.Web.Proxy
||
args
.
WebSession
.
UpStreamEndPoint
?.
Equals
(
serverConnection
.
UpStreamEndPoint
)
==
false
))
{
tcpConnectionFactory
.
Release
(
serverConnection
,
true
);
await
tcpConnectionFactory
.
Release
(
serverConnection
,
true
);
serverConnection
=
null
;
connectionChanged
=
true
;
}
...
...
@@ -226,7 +226,7 @@ namespace Titanium.Web.Proxy
}
//get new connection from pool
tcpConnectionFactory
.
Release
(
serverConnection
,
true
);
await
tcpConnectionFactory
.
Release
(
serverConnection
,
true
);
serverConnection
=
await
getServerConnection
(
args
,
false
,
clientConnection
.
NegotiatedApplicationProtocol
,
cancellationToken
);
attempt
++;
...
...
@@ -273,7 +273,7 @@ namespace Titanium.Web.Proxy
}
finally
{
tcpConnectionFactory
.
Release
(
serverConnection
,
serverConnectionClose
||
!
EnableConnectionPool
);
await
tcpConnectionFactory
.
Release
(
serverConnection
,
serverConnectionClose
||
!
EnableConnectionPool
);
}
}
...
...
Titanium.Web.Proxy/ResponseHandler.cs
View file @
6eb3a4f9
...
...
@@ -64,7 +64,7 @@ namespace Titanium.Web.Proxy
}
else
{
tcpConnectionFactory
.
Release
(
args
.
WebSession
.
ServerConnection
,
true
);
await
tcpConnectionFactory
.
Release
(
args
.
WebSession
.
ServerConnection
,
true
);
args
.
WebSession
.
ServerConnection
=
null
;
}
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
6eb3a4f9
...
...
@@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="Portable.BouncyCastle" Version="1.8.2" />
<PackageReference Include="StreamExtended" Version="1.0.17
0
-beta" />
<PackageReference Include="StreamExtended" Version="1.0.17
5
-beta" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
View file @
6eb3a4f9
...
...
@@ -14,7 +14,7 @@
<copyright>
Copyright
©
Titanium. All rights reserved.
</copyright>
<tags></tags>
<dependencies>
<dependency
id=
"StreamExtended"
version=
"1.0.1
64
"
/>
<dependency
id=
"StreamExtended"
version=
"1.0.1
75-beta
"
/>
<dependency
id=
"Portable.BouncyCastle"
version=
"1.8.2"
/>
</dependencies>
</metadata>
...
...
Titanium.Web.Proxy/TransparentClientHandler.cs
View file @
6eb3a4f9
...
...
@@ -115,7 +115,7 @@ namespace Titanium.Web.Proxy
await
TcpHelper
.
SendRaw
(
clientStream
,
serverStream
,
BufferPool
,
BufferSize
,
null
,
null
,
cancellationTokenSource
,
ExceptionFunc
);
tcpConnectionFactory
.
Release
(
connection
,
true
);
await
tcpConnectionFactory
.
Release
(
connection
,
true
);
return
;
}
...
...
Titanium.Web.Proxy/packages.config
View file @
6eb3a4f9
...
...
@@ -2,5 +2,5 @@
<
packages
>
<
package
id
=
"Portable.BouncyCastle"
version
=
"1.8.2"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.1
67
-beta"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.1
75
-beta"
targetFramework
=
"net45"
/>
</
packages
>
\ No newline at end of file
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