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
222f2776
Commit
222f2776
authored
May 07, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#425 add client/server connection create events
parent
07557b15
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
2 deletions
+42
-2
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+7
-2
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+35
-0
No files found.
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
222f2776
...
...
@@ -61,6 +61,13 @@ namespace Titanium.Web.Proxy.Network.Tcp
{
tcpClient
=
new
TcpClient
(
upStreamEndPoint
);
tcpClient
.
ReceiveTimeout
=
proxyServer
.
ConnectionTimeOutSeconds
*
1000
;
tcpClient
.
SendTimeout
=
proxyServer
.
ConnectionTimeOutSeconds
*
1000
;
tcpClient
.
SendBufferSize
=
proxyServer
.
BufferSize
;
tcpClient
.
ReceiveBufferSize
=
proxyServer
.
BufferSize
;
await
proxyServer
.
InvokeConnectionCreateEvent
(
tcpClient
,
false
);
// If this proxy uses another external proxy then create a tunnel request for HTTP/HTTPS connections
if
(
useUpstreamProxy
)
{
...
...
@@ -124,8 +131,6 @@ namespace Titanium.Web.Proxy.Network.Tcp
#endif
}
tcpClient
.
ReceiveTimeout
=
proxyServer
.
ConnectionTimeOutSeconds
*
1000
;
tcpClient
.
SendTimeout
=
proxyServer
.
ConnectionTimeOutSeconds
*
1000
;
}
catch
(
Exception
)
{
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
222f2776
...
...
@@ -279,6 +279,16 @@ namespace Titanium.Web.Proxy
/// </summary>
public
event
AsyncEventHandler
<
SessionEventArgs
>
AfterResponse
;
/// <summary>
/// Customize TcpClient used for client connection upon create.
/// </summary>
public
event
AsyncEventHandler
<
TcpClient
>
OnClientConnectionCreate
;
/// <summary>
/// Customize TcpClient used for server connection upon create.
/// </summary>
public
event
AsyncEventHandler
<
TcpClient
>
OnServerConnectionCreate
;
/// <summary>
/// Add a proxy end point.
/// </summary>
...
...
@@ -654,6 +664,10 @@ namespace Titanium.Web.Proxy
{
tcpClient
.
ReceiveTimeout
=
ConnectionTimeOutSeconds
*
1000
;
tcpClient
.
SendTimeout
=
ConnectionTimeOutSeconds
*
1000
;
tcpClient
.
SendBufferSize
=
BufferSize
;
tcpClient
.
ReceiveBufferSize
=
BufferSize
;
await
InvokeConnectionCreateEvent
(
tcpClient
,
true
);
using
(
var
clientConnection
=
new
TcpClientConnection
(
this
,
tcpClient
))
{
...
...
@@ -729,5 +743,26 @@ namespace Titanium.Web.Proxy
ServerConnectionCountChanged
?.
Invoke
(
this
,
EventArgs
.
Empty
);
}
/// <summary>
/// Invoke client/server tcp connection events if subscribed by API user.
/// </summary>
/// <param name="client">The TcpClient object.</param>
/// <param name="isClientConnection">Is this a client connection created event? If not then we would assume that its a server connection create event.</param>
/// <returns></returns>
internal
async
Task
InvokeConnectionCreateEvent
(
TcpClient
client
,
bool
isClientConnection
)
{
//client connection created
if
(
isClientConnection
&&
OnClientConnectionCreate
!=
null
)
{
await
OnClientConnectionCreate
.
InvokeAsync
(
this
,
client
,
ExceptionFunc
);
}
//server connection created
if
(!
isClientConnection
&&
OnServerConnectionCreate
!=
null
)
{
await
OnServerConnectionCreate
.
InvokeAsync
(
this
,
client
,
ExceptionFunc
);
}
}
}
}
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