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
ce8c03a3
Commit
ce8c03a3
authored
May 16, 2017
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event parallel invoke moved to extension class
parent
281c2a00
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
40 deletions
+45
-40
CertificateHandler.cs
Titanium.Web.Proxy/CertificateHandler.cs
+5
-22
FuncExtensions.cs
Titanium.Web.Proxy/Extensions/FuncExtensions.cs
+37
-0
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+1
-9
ResponseHandler.cs
Titanium.Web.Proxy/ResponseHandler.cs
+1
-9
Titanium.Web.Proxy.csproj
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+1
-0
No files found.
Titanium.Web.Proxy/CertificateHandler.cs
View file @
ce8c03a3
...
@@ -3,6 +3,7 @@ using System.Net.Security;
...
@@ -3,6 +3,7 @@ using System.Net.Security;
using
System.Security.Cryptography.X509Certificates
;
using
System.Security.Cryptography.X509Certificates
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.Extensions
;
namespace
Titanium.Web.Proxy
namespace
Titanium.Web.Proxy
{
{
...
@@ -32,17 +33,8 @@ namespace Titanium.Web.Proxy
...
@@ -32,17 +33,8 @@ namespace Titanium.Web.Proxy
SslPolicyErrors
=
sslPolicyErrors
SslPolicyErrors
=
sslPolicyErrors
};
};
//why is the sender null?
Delegate
[]
invocationList
=
ServerCertificateValidationCallback
.
GetInvocationList
();
ServerCertificateValidationCallback
.
InvokeParallel
(
null
,
args
);
Task
[]
handlerTasks
=
new
Task
[
invocationList
.
Length
];
for
(
int
i
=
0
;
i
<
invocationList
.
Length
;
i
++)
{
handlerTasks
[
i
]
=
((
Func
<
object
,
CertificateValidationEventArgs
,
Task
>)
invocationList
[
i
])(
null
,
args
);
}
Task
.
WhenAll
(
handlerTasks
).
Wait
();
return
args
.
IsValid
;
return
args
.
IsValid
;
}
}
...
@@ -108,17 +100,8 @@ namespace Titanium.Web.Proxy
...
@@ -108,17 +100,8 @@ namespace Titanium.Web.Proxy
ClientCertificate
=
clientCertificate
ClientCertificate
=
clientCertificate
};
};
//why is the sender null?
Delegate
[]
invocationList
=
ClientCertificateSelectionCallback
.
GetInvocationList
();
ClientCertificateSelectionCallback
.
InvokeParallel
(
null
,
args
);
Task
[]
handlerTasks
=
new
Task
[
invocationList
.
Length
];
for
(
int
i
=
0
;
i
<
invocationList
.
Length
;
i
++)
{
handlerTasks
[
i
]
=
((
Func
<
object
,
CertificateSelectionEventArgs
,
Task
>)
invocationList
[
i
])(
null
,
args
);
}
Task
.
WhenAll
(
handlerTasks
).
Wait
();
return
args
.
ClientCertificate
;
return
args
.
ClientCertificate
;
}
}
...
...
Titanium.Web.Proxy/Extensions/FuncExtensions.cs
0 → 100644
View file @
ce8c03a3
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Titanium.Web.Proxy.Extensions
{
internal
static
class
FuncExtensions
{
public
static
void
InvokeParallel
<
T
>(
this
Func
<
object
,
T
,
Task
>
callback
,
object
sender
,
T
args
)
{
Delegate
[]
invocationList
=
callback
.
GetInvocationList
();
Task
[]
handlerTasks
=
new
Task
[
invocationList
.
Length
];
for
(
int
i
=
0
;
i
<
invocationList
.
Length
;
i
++)
{
handlerTasks
[
i
]
=
((
Func
<
object
,
T
,
Task
>)
invocationList
[
i
])(
sender
,
args
);
}
Task
.
WhenAll
(
handlerTasks
).
Wait
();
}
public
static
async
Task
InvokeParallelAsync
<
T
>(
this
Func
<
object
,
T
,
Task
>
callback
,
object
sender
,
T
args
)
{
Delegate
[]
invocationList
=
callback
.
GetInvocationList
();
Task
[]
handlerTasks
=
new
Task
[
invocationList
.
Length
];
for
(
int
i
=
0
;
i
<
invocationList
.
Length
;
i
++)
{
handlerTasks
[
i
]
=
((
Func
<
object
,
T
,
Task
>)
invocationList
[
i
])(
sender
,
args
);
}
await
Task
.
WhenAll
(
handlerTasks
);
}
}
}
Titanium.Web.Proxy/RequestHandler.cs
View file @
ce8c03a3
...
@@ -486,15 +486,7 @@ namespace Titanium.Web.Proxy
...
@@ -486,15 +486,7 @@ namespace Titanium.Web.Proxy
//If user requested interception do it
//If user requested interception do it
if
(
BeforeRequest
!=
null
)
if
(
BeforeRequest
!=
null
)
{
{
var
invocationList
=
BeforeRequest
.
GetInvocationList
();
await
BeforeRequest
.
InvokeParallelAsync
(
this
,
args
);
var
handlerTasks
=
new
Task
[
invocationList
.
Length
];
for
(
var
i
=
0
;
i
<
invocationList
.
Length
;
i
++)
{
handlerTasks
[
i
]
=
((
Func
<
object
,
SessionEventArgs
,
Task
>)
invocationList
[
i
])(
this
,
args
);
}
await
Task
.
WhenAll
(
handlerTasks
);
}
}
//if upgrading to websocket then relay the requet without reading the contents
//if upgrading to websocket then relay the requet without reading the contents
...
...
Titanium.Web.Proxy/ResponseHandler.cs
View file @
ce8c03a3
...
@@ -41,15 +41,7 @@ namespace Titanium.Web.Proxy
...
@@ -41,15 +41,7 @@ namespace Titanium.Web.Proxy
//If user requested call back then do it
//If user requested call back then do it
if
(
BeforeResponse
!=
null
&&
!
args
.
WebSession
.
Response
.
ResponseLocked
)
if
(
BeforeResponse
!=
null
&&
!
args
.
WebSession
.
Response
.
ResponseLocked
)
{
{
Delegate
[]
invocationList
=
BeforeResponse
.
GetInvocationList
();
await
BeforeResponse
.
InvokeParallelAsync
(
this
,
args
);
Task
[]
handlerTasks
=
new
Task
[
invocationList
.
Length
];
for
(
int
i
=
0
;
i
<
invocationList
.
Length
;
i
++)
{
handlerTasks
[
i
]
=
((
Func
<
object
,
SessionEventArgs
,
Task
>)
invocationList
[
i
])(
this
,
args
);
}
await
Task
.
WhenAll
(
handlerTasks
);
}
}
if
(
args
.
ReRequest
)
if
(
args
.
ReRequest
)
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
ce8c03a3
...
@@ -73,6 +73,7 @@
...
@@ -73,6 +73,7 @@
<Compile
Include=
"EventArguments\CertificateSelectionEventArgs.cs"
/>
<Compile
Include=
"EventArguments\CertificateSelectionEventArgs.cs"
/>
<Compile
Include=
"EventArguments\CertificateValidationEventArgs.cs"
/>
<Compile
Include=
"EventArguments\CertificateValidationEventArgs.cs"
/>
<Compile
Include=
"Extensions\ByteArrayExtensions.cs"
/>
<Compile
Include=
"Extensions\ByteArrayExtensions.cs"
/>
<Compile
Include=
"Extensions\FuncExtensions.cs"
/>
<Compile
Include=
"Extensions\StringExtensions.cs"
/>
<Compile
Include=
"Extensions\StringExtensions.cs"
/>
<Compile
Include=
"Helpers\CustomBufferedStream.cs"
/>
<Compile
Include=
"Helpers\CustomBufferedStream.cs"
/>
<Compile
Include=
"Helpers\Network.cs"
/>
<Compile
Include=
"Helpers\Network.cs"
/>
...
...
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