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
a740f847
Commit
a740f847
authored
Apr 27, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update documentation
parent
aa04b0f9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
156 additions
and
123 deletions
+156
-123
AsyncEventHandler.cs
Titanium.Web.Proxy/EventArguments/AsyncEventHandler.cs
+7
-0
BeforeSslAuthenticateEventArgs.cs
...eb.Proxy/EventArguments/BeforeSslAuthenticateEventArgs.cs
+14
-0
CertificateSelectionEventArgs.cs
...Web.Proxy/EventArguments/CertificateSelectionEventArgs.cs
+7
-7
CertificateValidationEventArgs.cs
...eb.Proxy/EventArguments/CertificateValidationEventArgs.cs
+5
-4
DataEventArgs.cs
Titanium.Web.Proxy/EventArguments/DataEventArgs.cs
+12
-0
MultipartRequestPartSentEventArgs.cs
...Proxy/EventArguments/MultipartRequestPartSentEventArgs.cs
+9
-0
SessionEventArgs.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+28
-31
ExceptionHandler.cs
Titanium.Web.Proxy/ExceptionHandler.cs
+4
-0
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+70
-81
No files found.
Titanium.Web.Proxy/EventArguments/AsyncEventHandler.cs
View file @
a740f847
...
...
@@ -2,5 +2,12 @@
namespace
Titanium.Web.Proxy.EventArguments
{
/// <summary>
/// A generic asynchronous event handler used by this proxy.
/// </summary>
/// <typeparam name="TEventArgs"></typeparam>
/// <param name="sender">The proxy server instance.</param>
/// <param name="e">The event arguments.</param>
/// <returns></returns>
public
delegate
Task
AsyncEventHandler
<
in
TEventArgs
>(
object
sender
,
TEventArgs
e
);
}
Titanium.Web.Proxy/EventArguments/BeforeSslAuthenticateEventArgs.cs
View file @
a740f847
...
...
@@ -3,6 +3,9 @@ using System.Threading;
namespace
Titanium.Web.Proxy.EventArguments
{
/// <summary>
/// This is used in transparent endpoint before authenticating client.
/// </summary>
public
class
BeforeSslAuthenticateEventArgs
:
EventArgs
{
internal
readonly
CancellationTokenSource
TaskCancellationSource
;
...
...
@@ -12,10 +15,21 @@ namespace Titanium.Web.Proxy.EventArguments
TaskCancellationSource
=
taskCancellationSource
;
}
/// <summary>
/// The server name indication hostname.
/// </summary>
public
string
SniHostName
{
get
;
internal
set
;
}
/// <summary>
/// Should we decrypt the SSL request?
/// If true we decrypt with fake certificate.
/// If false we relay the connection to the hostname mentioned in SniHostname.
/// </summary>
public
bool
DecryptSsl
{
get
;
set
;
}
=
true
;
/// <summary>
/// Terminate the request abruptly.
/// </summary>
public
void
TerminateSession
()
{
TaskCancellationSource
.
Cancel
();
...
...
Titanium.Web.Proxy/EventArguments/CertificateSelectionEventArgs.cs
View file @
a740f847
...
...
@@ -4,37 +4,37 @@ using System.Security.Cryptography.X509Certificates;
namespace
Titanium.Web.Proxy.EventArguments
{
/// <summary>
/// An argument passed on to user for client certificate selection during mutual SSL authentication
/// An argument passed on to user for client certificate selection during mutual SSL authentication
.
/// </summary>
public
class
CertificateSelectionEventArgs
:
EventArgs
{
/// <summary>
///
Sender object
.
///
The proxy server instance
.
/// </summary>
public
object
Sender
{
get
;
internal
set
;
}
/// <summary>
/// T
arget ho
st.
/// T
he host to which we are authenticating again
st.
/// </summary>
public
string
TargetHost
{
get
;
internal
set
;
}
/// <summary>
/// Local certificates.
/// Local certificates
with matching issuers
.
/// </summary>
public
X509CertificateCollection
LocalCertificates
{
get
;
internal
set
;
}
/// <summary>
/// Remote certificate.
/// Remote certificate
of the server
.
/// </summary>
public
X509Certificate
RemoteCertificate
{
get
;
internal
set
;
}
/// <summary>
/// Acceptable issuers.
/// Acceptable issuers
mentioned by server
.
/// </summary>
public
string
[]
AcceptableIssuers
{
get
;
internal
set
;
}
/// <summary>
/// Client Certificate.
/// Client Certificate
we selected
.
/// </summary>
public
X509Certificate
ClientCertificate
{
get
;
set
;
}
}
...
...
Titanium.Web.Proxy/EventArguments/CertificateValidationEventArgs.cs
View file @
a740f847
...
...
@@ -5,17 +5,18 @@ using System.Security.Cryptography.X509Certificates;
namespace
Titanium.Web.Proxy.EventArguments
{
/// <summary>
/// An argument passed on to the user for validating the server certificate during SSL authentication
/// An argument passed on to the user for validating the server certificate
/// during SSL authentication.
/// </summary>
public
class
CertificateValidationEventArgs
:
EventArgs
{
/// <summary>
///
Certificate
///
Server certificate.
/// </summary>
public
X509Certificate
Certificate
{
get
;
internal
set
;
}
/// <summary>
/// Certificate chain
/// Certificate chain
.
/// </summary>
public
X509Chain
Chain
{
get
;
internal
set
;
}
...
...
@@ -25,7 +26,7 @@ namespace Titanium.Web.Proxy.EventArguments
public
SslPolicyErrors
SslPolicyErrors
{
get
;
internal
set
;
}
/// <summary>
///
is a valid certificate
?
///
Is the given server certificate is valid
?
/// </summary>
public
bool
IsValid
{
get
;
set
;
}
}
...
...
Titanium.Web.Proxy/EventArguments/DataEventArgs.cs
View file @
a740f847
...
...
@@ -2,6 +2,9 @@ using System;
namespace
Titanium.Web.Proxy.EventArguments
{
/// <summary>
/// Wraps the data sent/received by a proxy server instance.
/// </summary>
public
class
DataEventArgs
:
EventArgs
{
internal
DataEventArgs
(
byte
[]
buffer
,
int
offset
,
int
count
)
...
...
@@ -11,10 +14,19 @@ namespace Titanium.Web.Proxy.EventArguments
Count
=
count
;
}
/// <summary>
/// The buffer with data.
/// </summary>
public
byte
[]
Buffer
{
get
;
}
/// <summary>
/// Offset in Buffer where valid data begins.
/// </summary>
public
int
Offset
{
get
;
}
/// <summary>
/// Length from offset in Buffer with valid data.
/// </summary>
public
int
Count
{
get
;
}
}
}
Titanium.Web.Proxy/EventArguments/MultipartRequestPartSentEventArgs.cs
View file @
a740f847
...
...
@@ -3,6 +3,9 @@ using Titanium.Web.Proxy.Http;
namespace
Titanium.Web.Proxy.EventArguments
{
/// <summary>
/// Class that wraps the multipart sent request arguments.
/// </summary>
public
class
MultipartRequestPartSentEventArgs
:
EventArgs
{
public
MultipartRequestPartSentEventArgs
(
string
boundary
,
HeaderCollection
headers
)
...
...
@@ -11,8 +14,14 @@ namespace Titanium.Web.Proxy.EventArguments
Headers
=
headers
;
}
/// <summary>
/// Boundary
/// </summary>
public
string
Boundary
{
get
;
}
/// <summary>
/// The header collection.
/// </summary>
public
HeaderCollection
Headers
{
get
;
}
}
}
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
a740f847
...
...
@@ -15,10 +15,10 @@ using Titanium.Web.Proxy.Models;
namespace
Titanium.Web.Proxy.EventArguments
{
/// <summary>
/// Holds info related to a single proxy session (single request/response sequence)
/// A proxy session is bounded to a single connection from client
/// Holds info related to a single proxy session (single request/response sequence)
.
/// A proxy session is bounded to a single connection from client
.
/// A proxy session ends when client terminates connection to proxy
/// or when server terminates connection from proxy
/// or when server terminates connection from proxy
.
/// </summary>
public
class
SessionEventArgs
:
SessionEventArgsBase
{
...
...
@@ -47,7 +47,7 @@ namespace Titanium.Web.Proxy.EventArguments
private
bool
hasMulipartEventSubscribers
=>
MultipartRequestPartSent
!=
null
;
/// <summary>
/// Should we send the request again
/// Should we send the request again
?
/// </summary>
public
bool
ReRequest
{
...
...
@@ -346,9 +346,10 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// Gets the request body as bytes
/// Gets the request body as bytes
.
/// </summary>
/// <returns></returns>
/// <param name="cancellationToken"></param>
/// <returns>The body as bytes.</returns>
public
async
Task
<
byte
[
]>
GetRequestBody
(
CancellationToken
cancellationToken
=
default
)
{
if
(!
WebSession
.
Request
.
IsBodyRead
)
...
...
@@ -360,9 +361,10 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// Gets the request body as string
/// Gets the request body as string
.
/// </summary>
/// <returns></returns>
/// <param name="cancellationToken">Cancellation token for this async task is optional.</param>
/// <returns>The body as string.</returns>
public
async
Task
<
string
>
GetRequestBodyAsString
(
CancellationToken
cancellationToken
=
default
)
{
if
(!
WebSession
.
Request
.
IsBodyRead
)
...
...
@@ -374,9 +376,9 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// Sets the request body
/// Sets the request body
.
/// </summary>
/// <param name="body"></param>
/// <param name="body">
The request body bytes.
</param>
public
void
SetRequestBody
(
byte
[]
body
)
{
var
request
=
WebSession
.
Request
;
...
...
@@ -389,9 +391,9 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// Sets the body with the specified string
/// Sets the body with the specified string
.
/// </summary>
/// <param name="body"></param>
/// <param name="body">
The request body string to set.
</param>
public
void
SetRequestBodyString
(
string
body
)
{
if
(
WebSession
.
Request
.
Locked
)
...
...
@@ -403,7 +405,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// Gets the response body as byte
array
/// Gets the response body as byte
s.
/// </summary>
/// <returns></returns>
public
async
Task
<
byte
[
]>
GetResponseBody
(
CancellationToken
cancellationToken
=
default
)
...
...
@@ -417,9 +419,9 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// Gets the response body as string
/// Gets the response body as string
.
/// </summary>
/// <returns></returns>
/// <returns>
The string body.
</returns>
public
async
Task
<
string
>
GetResponseBodyAsString
(
CancellationToken
cancellationToken
=
default
)
{
if
(!
WebSession
.
Response
.
IsBodyRead
)
...
...
@@ -431,7 +433,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// Set the response body bytes
/// Set the response body bytes
.
/// </summary>
/// <param name="body"></param>
public
void
SetResponseBody
(
byte
[]
body
)
...
...
@@ -446,7 +448,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// Replace the response body with the specified string
/// Replace the response body with the specified string
.
/// </summary>
/// <param name="body"></param>
public
void
SetResponseBodyString
(
string
body
)
...
...
@@ -462,9 +464,8 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// Before request is made to server
/// Respond with the specified HTML string to client
/// and ignore the request
/// Before request is made to server respond with the specified HTML string to client
/// and ignore the request.
/// </summary>
/// <param name="html"></param>
/// <param name="headers"></param>
...
...
@@ -483,9 +484,8 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// Before request is made to server
/// Respond with the specified byte[] to client
/// and ignore the request
/// Before request is made to server respond with the specified byte[] to client
/// and ignore the request.
/// </summary>
/// <param name="result"></param>
/// <param name="headers"></param>
...
...
@@ -501,9 +501,8 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// Before request is made to server
/// Respond with the specified HTML string to client
/// and the specified status
/// and ignore the request
/// respond with the specified HTML string and the specified status to client.
/// And then ignore the request.
/// </summary>
/// <param name="html"></param>
/// <param name="status"></param>
...
...
@@ -520,10 +519,8 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// Before request is made to server
/// Respond with the specified byte[] to client
/// and the specified status
/// and ignore the request
/// Before request is made to server respond with the specified byte[],
/// the specified status to client. And then ignore the request.
/// </summary>
/// <param name="result"></param>
/// <param name="status"></param>
...
...
@@ -540,7 +537,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// Redirect to URL.
/// Redirect to
provided
URL.
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
...
...
Titanium.Web.Proxy/ExceptionHandler.cs
View file @
a740f847
...
...
@@ -2,5 +2,9 @@ using System;
namespace
Titanium.Web.Proxy
{
/// <summary>
/// A delegate to catch exceptions occuring in proxy.
/// </summary>
/// <param name="exception">The exception occurred in proxy.</param>
public
delegate
void
ExceptionHandler
(
Exception
exception
);
}
Titanium.Web.Proxy/ProxyServer.cs
View file @
a740f847
This diff is collapsed.
Click to expand it.
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