Commit a740f847 authored by justcoding121's avatar justcoding121

Update documentation

parent aa04b0f9
...@@ -2,5 +2,12 @@ ...@@ -2,5 +2,12 @@
namespace Titanium.Web.Proxy.EventArguments 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); public delegate Task AsyncEventHandler<in TEventArgs>(object sender, TEventArgs e);
} }
...@@ -3,6 +3,9 @@ using System.Threading; ...@@ -3,6 +3,9 @@ using System.Threading;
namespace Titanium.Web.Proxy.EventArguments namespace Titanium.Web.Proxy.EventArguments
{ {
/// <summary>
/// This is used in transparent endpoint before authenticating client.
/// </summary>
public class BeforeSslAuthenticateEventArgs : EventArgs public class BeforeSslAuthenticateEventArgs : EventArgs
{ {
internal readonly CancellationTokenSource TaskCancellationSource; internal readonly CancellationTokenSource TaskCancellationSource;
...@@ -12,10 +15,21 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -12,10 +15,21 @@ namespace Titanium.Web.Proxy.EventArguments
TaskCancellationSource = taskCancellationSource; TaskCancellationSource = taskCancellationSource;
} }
/// <summary>
/// The server name indication hostname.
/// </summary>
public string SniHostName { get; internal set; } 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; public bool DecryptSsl { get; set; } = true;
/// <summary>
/// Terminate the request abruptly.
/// </summary>
public void TerminateSession() public void TerminateSession()
{ {
TaskCancellationSource.Cancel(); TaskCancellationSource.Cancel();
......
...@@ -4,37 +4,37 @@ using System.Security.Cryptography.X509Certificates; ...@@ -4,37 +4,37 @@ using System.Security.Cryptography.X509Certificates;
namespace Titanium.Web.Proxy.EventArguments namespace Titanium.Web.Proxy.EventArguments
{ {
/// <summary> /// <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> /// </summary>
public class CertificateSelectionEventArgs : EventArgs public class CertificateSelectionEventArgs : EventArgs
{ {
/// <summary> /// <summary>
/// Sender object. /// The proxy server instance.
/// </summary> /// </summary>
public object Sender { get; internal set; } public object Sender { get; internal set; }
/// <summary> /// <summary>
/// Target host. /// The host to which we are authenticating against.
/// </summary> /// </summary>
public string TargetHost { get; internal set; } public string TargetHost { get; internal set; }
/// <summary> /// <summary>
/// Local certificates. /// Local certificates with matching issuers.
/// </summary> /// </summary>
public X509CertificateCollection LocalCertificates { get; internal set; } public X509CertificateCollection LocalCertificates { get; internal set; }
/// <summary> /// <summary>
/// Remote certificate. /// Remote certificate of the server.
/// </summary> /// </summary>
public X509Certificate RemoteCertificate { get; internal set; } public X509Certificate RemoteCertificate { get; internal set; }
/// <summary> /// <summary>
/// Acceptable issuers. /// Acceptable issuers mentioned by server.
/// </summary> /// </summary>
public string[] AcceptableIssuers { get; internal set; } public string[] AcceptableIssuers { get; internal set; }
/// <summary> /// <summary>
/// Client Certificate. /// Client Certificate we selected.
/// </summary> /// </summary>
public X509Certificate ClientCertificate { get; set; } public X509Certificate ClientCertificate { get; set; }
} }
......
...@@ -5,17 +5,18 @@ using System.Security.Cryptography.X509Certificates; ...@@ -5,17 +5,18 @@ using System.Security.Cryptography.X509Certificates;
namespace Titanium.Web.Proxy.EventArguments namespace Titanium.Web.Proxy.EventArguments
{ {
/// <summary> /// <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> /// </summary>
public class CertificateValidationEventArgs : EventArgs public class CertificateValidationEventArgs : EventArgs
{ {
/// <summary> /// <summary>
/// Certificate /// Server certificate.
/// </summary> /// </summary>
public X509Certificate Certificate { get; internal set; } public X509Certificate Certificate { get; internal set; }
/// <summary> /// <summary>
/// Certificate chain /// Certificate chain.
/// </summary> /// </summary>
public X509Chain Chain { get; internal set; } public X509Chain Chain { get; internal set; }
...@@ -25,7 +26,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -25,7 +26,7 @@ namespace Titanium.Web.Proxy.EventArguments
public SslPolicyErrors SslPolicyErrors { get; internal set; } public SslPolicyErrors SslPolicyErrors { get; internal set; }
/// <summary> /// <summary>
/// is a valid certificate? /// Is the given server certificate is valid?
/// </summary> /// </summary>
public bool IsValid { get; set; } public bool IsValid { get; set; }
} }
......
...@@ -2,6 +2,9 @@ using System; ...@@ -2,6 +2,9 @@ using System;
namespace Titanium.Web.Proxy.EventArguments namespace Titanium.Web.Proxy.EventArguments
{ {
/// <summary>
/// Wraps the data sent/received by a proxy server instance.
/// </summary>
public class DataEventArgs : EventArgs public class DataEventArgs : EventArgs
{ {
internal DataEventArgs(byte[] buffer, int offset, int count) internal DataEventArgs(byte[] buffer, int offset, int count)
...@@ -11,10 +14,19 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -11,10 +14,19 @@ namespace Titanium.Web.Proxy.EventArguments
Count = count; Count = count;
} }
/// <summary>
/// The buffer with data.
/// </summary>
public byte[] Buffer { get; } public byte[] Buffer { get; }
/// <summary>
/// Offset in Buffer where valid data begins.
/// </summary>
public int Offset { get; } public int Offset { get; }
/// <summary>
/// Length from offset in Buffer with valid data.
/// </summary>
public int Count { get; } public int Count { get; }
} }
} }
...@@ -3,6 +3,9 @@ using Titanium.Web.Proxy.Http; ...@@ -3,6 +3,9 @@ using Titanium.Web.Proxy.Http;
namespace Titanium.Web.Proxy.EventArguments namespace Titanium.Web.Proxy.EventArguments
{ {
/// <summary>
/// Class that wraps the multipart sent request arguments.
/// </summary>
public class MultipartRequestPartSentEventArgs : EventArgs public class MultipartRequestPartSentEventArgs : EventArgs
{ {
public MultipartRequestPartSentEventArgs(string boundary, HeaderCollection headers) public MultipartRequestPartSentEventArgs(string boundary, HeaderCollection headers)
...@@ -11,8 +14,14 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -11,8 +14,14 @@ namespace Titanium.Web.Proxy.EventArguments
Headers = headers; Headers = headers;
} }
/// <summary>
/// Boundary
/// </summary>
public string Boundary { get; } public string Boundary { get; }
/// <summary>
/// The header collection.
/// </summary>
public HeaderCollection Headers { get; } public HeaderCollection Headers { get; }
} }
} }
...@@ -15,10 +15,10 @@ using Titanium.Web.Proxy.Models; ...@@ -15,10 +15,10 @@ using Titanium.Web.Proxy.Models;
namespace Titanium.Web.Proxy.EventArguments namespace Titanium.Web.Proxy.EventArguments
{ {
/// <summary> /// <summary>
/// Holds info related to a single proxy session (single request/response sequence) /// 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 is bounded to a single connection from client.
/// A proxy session ends when client terminates connection to proxy /// 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> /// </summary>
public class SessionEventArgs : SessionEventArgsBase public class SessionEventArgs : SessionEventArgsBase
{ {
...@@ -47,7 +47,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -47,7 +47,7 @@ namespace Titanium.Web.Proxy.EventArguments
private bool hasMulipartEventSubscribers => MultipartRequestPartSent != null; private bool hasMulipartEventSubscribers => MultipartRequestPartSent != null;
/// <summary> /// <summary>
/// Should we send the request again /// Should we send the request again ?
/// </summary> /// </summary>
public bool ReRequest public bool ReRequest
{ {
...@@ -346,9 +346,10 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -346,9 +346,10 @@ namespace Titanium.Web.Proxy.EventArguments
} }
/// <summary> /// <summary>
/// Gets the request body as bytes /// Gets the request body as bytes.
/// </summary> /// </summary>
/// <returns></returns> /// <param name="cancellationToken"></param>
/// <returns>The body as bytes.</returns>
public async Task<byte[]> GetRequestBody(CancellationToken cancellationToken = default) public async Task<byte[]> GetRequestBody(CancellationToken cancellationToken = default)
{ {
if (!WebSession.Request.IsBodyRead) if (!WebSession.Request.IsBodyRead)
...@@ -360,9 +361,10 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -360,9 +361,10 @@ namespace Titanium.Web.Proxy.EventArguments
} }
/// <summary> /// <summary>
/// Gets the request body as string /// Gets the request body as string.
/// </summary> /// </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) public async Task<string> GetRequestBodyAsString(CancellationToken cancellationToken = default)
{ {
if (!WebSession.Request.IsBodyRead) if (!WebSession.Request.IsBodyRead)
...@@ -374,9 +376,9 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -374,9 +376,9 @@ namespace Titanium.Web.Proxy.EventArguments
} }
/// <summary> /// <summary>
/// Sets the request body /// Sets the request body.
/// </summary> /// </summary>
/// <param name="body"></param> /// <param name="body">The request body bytes.</param>
public void SetRequestBody(byte[] body) public void SetRequestBody(byte[] body)
{ {
var request = WebSession.Request; var request = WebSession.Request;
...@@ -389,9 +391,9 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -389,9 +391,9 @@ namespace Titanium.Web.Proxy.EventArguments
} }
/// <summary> /// <summary>
/// Sets the body with the specified string /// Sets the body with the specified string.
/// </summary> /// </summary>
/// <param name="body"></param> /// <param name="body">The request body string to set.</param>
public void SetRequestBodyString(string body) public void SetRequestBodyString(string body)
{ {
if (WebSession.Request.Locked) if (WebSession.Request.Locked)
...@@ -403,7 +405,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -403,7 +405,7 @@ namespace Titanium.Web.Proxy.EventArguments
} }
/// <summary> /// <summary>
/// Gets the response body as byte array /// Gets the response body as bytes.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<byte[]> GetResponseBody(CancellationToken cancellationToken = default) public async Task<byte[]> GetResponseBody(CancellationToken cancellationToken = default)
...@@ -417,9 +419,9 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -417,9 +419,9 @@ namespace Titanium.Web.Proxy.EventArguments
} }
/// <summary> /// <summary>
/// Gets the response body as string /// Gets the response body as string.
/// </summary> /// </summary>
/// <returns></returns> /// <returns>The string body.</returns>
public async Task<string> GetResponseBodyAsString(CancellationToken cancellationToken = default) public async Task<string> GetResponseBodyAsString(CancellationToken cancellationToken = default)
{ {
if (!WebSession.Response.IsBodyRead) if (!WebSession.Response.IsBodyRead)
...@@ -431,7 +433,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -431,7 +433,7 @@ namespace Titanium.Web.Proxy.EventArguments
} }
/// <summary> /// <summary>
/// Set the response body bytes /// Set the response body bytes.
/// </summary> /// </summary>
/// <param name="body"></param> /// <param name="body"></param>
public void SetResponseBody(byte[] body) public void SetResponseBody(byte[] body)
...@@ -446,7 +448,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -446,7 +448,7 @@ namespace Titanium.Web.Proxy.EventArguments
} }
/// <summary> /// <summary>
/// Replace the response body with the specified string /// Replace the response body with the specified string.
/// </summary> /// </summary>
/// <param name="body"></param> /// <param name="body"></param>
public void SetResponseBodyString(string body) public void SetResponseBodyString(string body)
...@@ -462,9 +464,8 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -462,9 +464,8 @@ namespace Titanium.Web.Proxy.EventArguments
} }
/// <summary> /// <summary>
/// Before request is made to server /// Before request is made to server respond with the specified HTML string to client
/// Respond with the specified HTML string to client /// and ignore the request.
/// and ignore the request
/// </summary> /// </summary>
/// <param name="html"></param> /// <param name="html"></param>
/// <param name="headers"></param> /// <param name="headers"></param>
...@@ -483,9 +484,8 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -483,9 +484,8 @@ namespace Titanium.Web.Proxy.EventArguments
} }
/// <summary> /// <summary>
/// Before request is made to server /// Before request is made to server respond with the specified byte[] to client
/// Respond with the specified byte[] to client /// and ignore the request.
/// and ignore the request
/// </summary> /// </summary>
/// <param name="result"></param> /// <param name="result"></param>
/// <param name="headers"></param> /// <param name="headers"></param>
...@@ -501,9 +501,8 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -501,9 +501,8 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary> /// <summary>
/// Before request is made to server  /// Before request is made to server 
/// Respond with the specified HTML string to client /// respond with the specified HTML string and the specified status to client.
/// and the specified status /// And then ignore the request. 
/// and ignore the request 
/// </summary> /// </summary>
/// <param name="html"></param> /// <param name="html"></param>
/// <param name="status"></param> /// <param name="status"></param>
...@@ -520,10 +519,8 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -520,10 +519,8 @@ namespace Titanium.Web.Proxy.EventArguments
} }
/// <summary> /// <summary>
/// Before request is made to server /// Before request is made to server respond with the specified byte[],
/// Respond with the specified byte[] to client /// the specified status to client. And then ignore the request.
/// and the specified status
/// and ignore the request
/// </summary> /// </summary>
/// <param name="result"></param> /// <param name="result"></param>
/// <param name="status"></param> /// <param name="status"></param>
...@@ -540,7 +537,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -540,7 +537,7 @@ namespace Titanium.Web.Proxy.EventArguments
} }
/// <summary> /// <summary>
/// Redirect to URL. /// Redirect to provided URL.
/// </summary> /// </summary>
/// <param name="url"></param> /// <param name="url"></param>
/// <returns></returns> /// <returns></returns>
......
...@@ -2,5 +2,9 @@ using System; ...@@ -2,5 +2,9 @@ using System;
namespace Titanium.Web.Proxy 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); public delegate void ExceptionHandler(Exception exception);
} }
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment