Commit 584af5de authored by justcoding121's avatar justcoding121

Fix build failure

parent df1cad80
......@@ -11,11 +11,11 @@ namespace Titanium.Web.Proxy
/// <summary>
/// Call back to override server certificate validation
/// </summary>
/// <param name="sender"></param>
/// <param name="certificate"></param>
/// <param name="chain"></param>
/// <param name="sslPolicyErrors"></param>
/// <returns></returns>
/// <param name="sender">The sender object.</param>
/// <param name="certificate">The remote certificate.</param>
/// <param name="chain">The certificate chain.</param>
/// <param name="sslPolicyErrors">Ssl policy errors</param>
/// <returns>Return true if valid certificate.</returns>
internal bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
......@@ -47,11 +47,11 @@ namespace Titanium.Web.Proxy
/// <summary>
/// Call back to select client certificate used for mutual authentication
/// </summary>
/// <param name="sender"></param>
/// <param name="targetHost"></param>
/// <param name="localCertificates"></param>
/// <param name="remoteCertificate"></param>
/// <param name="acceptableIssuers"></param>
/// <param name="sender">The sender.</param>
/// <param name="targetHost">The remote hostname.</param>
/// <param name="localCertificates">Selected local certificates by SslStream.</param>
/// <param name="remoteCertificate">The remote certificate of server.</param>
/// <param name="acceptableIssuers">The acceptable issues for client certificate as listed by server.</param>
/// <returns></returns>
internal X509Certificate SelectClientCertificate(object sender, string targetHost,
X509CertificateCollection localCertificates,
......
......@@ -24,9 +24,9 @@ namespace Titanium.Web.Proxy
/// This is called when client is aware of proxy
/// So for HTTPS requests client would send CONNECT header to negotiate a secure tcp tunnel via proxy
/// </summary>
/// <param name="endPoint"></param>
/// <param name="tcpClient"></param>
/// <returns></returns>
/// <param name="endPoint">The explicit endpoint.</param>
/// <param name="tcpClient">The client.</param>
/// <returns>The task.</returns>
private async Task HandleClient(ExplicitProxyEndPoint endPoint, TcpClient tcpClient)
{
var cancellationTokenSource = new CancellationTokenSource();
......
using System;
#if NETSTANDARD2_0
using System.Runtime.InteropServices;
#endif
namespace Titanium.Web.Proxy.Helpers
{
/// <summary>
......@@ -18,9 +21,8 @@ namespace Titanium.Web.Proxy.Helpers
/// cache for Windows platform check
/// </summary>
/// <returns></returns>
private static readonly Lazy<bool> isRunningOnWindows =
new Lazy<bool>(() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
private static readonly Lazy<bool> isRunningOnWindows
= new Lazy<bool>(() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
#endif
/// <summary>
......
......@@ -13,8 +13,14 @@ namespace Titanium.Web.Proxy
{
public partial class ProxyServer
{
/// <summary>
/// Callback to authorize clients of this proxy instance.
/// </summary>
/// <param name="session">The session event arguments.</param>
/// <returns>True if authorized.</returns>
private async Task<bool> CheckAuthorization(SessionEventArgsBase session)
{
//If we are not authorizing clients return true
if (AuthenticateUserFunc == null)
{
return true;
......@@ -70,6 +76,11 @@ namespace Titanium.Web.Proxy
}
}
/// <summary>
/// Create an authentication required response.
/// </summary>
/// <param name="description">Response description.</param>
/// <returns></returns>
private Response CreateAuthentication407Response(string description)
{
var response = new Response
......
......@@ -27,19 +27,22 @@ namespace Titanium.Web.Proxy
EnableWinAuth && RunTime.IsWindows && !RunTime.IsRunningOnMono;
/// <summary>
/// This is the core request handler method for a particular connection from client
/// This is the core request handler method for a particular connection from client.
/// Will create new session (request/response) sequence until
/// client/server abruptly terminates connection or by normal HTTP termination
/// client/server abruptly terminates connection or by normal HTTP termination.
/// </summary>
/// <param name="client"></param>
/// <param name="clientStream"></param>
/// <param name="clientStreamReader"></param>
/// <param name="clientStreamWriter"></param>
/// <param name="cancellationTokenSource"></param>
/// <param name="httpsConnectHostname"></param>
/// <param name="endPoint"></param>
/// <param name="connectRequest"></param>
/// <param name="isTransparentEndPoint"></param>
/// <param name="endPoint">The proxy endpoint.</param>
/// <param name="client">The client.</param>
/// <param name="clientStream">The client stream.</param>
/// <param name="clientStreamReader">The client stream reader.</param>
/// <param name="clientStreamWriter">The client stream writer.</param>
/// <param name="cancellationTokenSource">The cancellation token source for this async task.</param>
/// <param name="httpsConnectHostname">
/// The https hostname as appeared in CONNECT request if this is a HTTPS request from
/// explicit endpoint.
/// </param>
/// <param name="connectRequest">The Connect request if this is a HTTPS request from explicit endpoint.</param>
/// <param name="isTransparentEndPoint">Is this a request from transparent endpoint?</param>
/// <returns></returns>
private async Task HandleHttpSessionRequest(ProxyEndPoint endPoint, TcpClient client,
CustomBufferedStream clientStream, CustomBinaryReader clientStreamReader,
......@@ -272,9 +275,9 @@ namespace Titanium.Web.Proxy
/// <summary>
/// Handle a specific session (request/response sequence)
/// </summary>
/// <param name="connection"></param>
/// <param name="args"></param>
/// <returns>True if close the connection</returns>
/// <param name="connection">The tcp connection.</param>
/// <param name="args">The session event arguments.</param>
/// <returns></returns>
private async Task HandleHttpSessionRequestInternal(TcpConnection connection, SessionEventArgs args)
{
try
......@@ -355,11 +358,11 @@ namespace Titanium.Web.Proxy
}
/// <summary>
/// Create a Server Connection
/// Create a server connection.
/// </summary>
/// <param name="args"></param>
/// <param name="isConnect"></param>
/// <param name="cancellationToken"></param>
/// <param name="args">The session event arguments.</param>
/// <param name="isConnect">Is this a CONNECT request.</param>
/// <param name="cancellationToken">The cancellation token for this async task.</param>
/// <returns></returns>
private async Task<TcpConnection> GetServerConnection(SessionEventArgsBase args, bool isConnect,
CancellationToken cancellationToken)
......@@ -385,7 +388,7 @@ namespace Titanium.Web.Proxy
}
/// <summary>
/// prepare the request headers so that we can avoid encodings not parsable by this proxy
/// Prepare the request headers so that we can avoid encodings not parsable by this proxy
/// </summary>
/// <param name="requestHeaders"></param>
private void PrepareRequestHeaders(HeaderCollection requestHeaders)
......@@ -398,6 +401,11 @@ namespace Titanium.Web.Proxy
requestHeaders.FixProxyHeaders();
}
/// <summary>
/// Invoke before request handler if it is set.
/// </summary>
/// <param name="args">The session event arguments.</param>
/// <returns></returns>
private async Task InvokeBeforeRequest(SessionEventArgs args)
{
if (BeforeRequest != null)
......
......@@ -9,15 +9,15 @@ using Titanium.Web.Proxy.Network.WinAuth.Security;
namespace Titanium.Web.Proxy
{
/// <summary>
/// Handle the response from server
/// Handle the response from server.
/// </summary>
partial class ProxyServer
{
/// <summary>
/// Called asynchronously when a request was successfully and we received the response
/// Called asynchronously when a request was successfully and we received the response.
/// </summary>
/// <param name="args"></param>
/// <returns>true if client/server connection was terminated (and disposed) </returns>
/// <param name="args">The session event arguments.</param>
/// <returns> The task.</returns>
private async Task HandleHttpSessionResponse(SessionEventArgs args)
{
try
......@@ -129,6 +129,11 @@ namespace Titanium.Web.Proxy
}
}
/// <summary>
/// Invoke before response if it is set.
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
private async Task InvokeBeforeResponse(SessionEventArgs args)
{
if (BeforeResponse != null)
......@@ -137,6 +142,11 @@ namespace Titanium.Web.Proxy
}
}
/// <summary>
/// Invoke after response if it is set.
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
private async Task InvokeAfterResponse(SessionEventArgs args)
{
if (AfterResponse != null)
......
......@@ -17,11 +17,11 @@ namespace Titanium.Web.Proxy
partial class ProxyServer
{
/// <summary>
/// This is called when this proxy acts as a reverse proxy (like a real http server)
/// This is called when this proxy acts as a reverse proxy (like a real http server).
/// So for HTTPS requests we would start SSL negotiation right away without expecting a CONNECT request from client
/// </summary>
/// <param name="endPoint"></param>
/// <param name="tcpClient"></param>
/// <param name="endPoint">The transparent endpoint.</param>
/// <param name="tcpClient">The client.</param>
/// <returns></returns>
private async Task HandleClient(TransparentProxyEndPoint endPoint, TcpClient tcpClient)
{
......@@ -44,8 +44,11 @@ namespace Titanium.Web.Proxy
{
httpsHostName = clientHelloInfo.GetServerName() ?? endPoint.GenericCertificateName;
var args = new BeforeSslAuthenticateEventArgs(cancellationTokenSource);
args.SniHostName = httpsHostName;
var args = new BeforeSslAuthenticateEventArgs(cancellationTokenSource)
{
SniHostName = httpsHostName
};
await endPoint.InvokeBeforeSslAuthenticate(this, args, ExceptionFunc);
if (cancellationTokenSource.IsCancellationRequested)
......
......@@ -13,7 +13,9 @@ namespace Titanium.Web.Proxy
{
public partial class ProxyServer
{
//possible header names
/// <summary>
/// possible header names.
/// </summary>
private static readonly HashSet<string> authHeaderNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"WWW-Authenticate",
......@@ -24,6 +26,9 @@ namespace Titanium.Web.Proxy
"KerberosAuthorization"
};
/// <summary>
/// supported authentication schemes.
/// </summary>
private static readonly HashSet<string> authSchemes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"NTLM",
......@@ -32,13 +37,12 @@ namespace Titanium.Web.Proxy
};
/// <summary>
/// Handle windows NTLM authentication
/// Can expand this for Kerberos in future
/// Handle windows NTLM/Kerberos authentication.
/// Note: NTLM/Kerberos cannot do a man in middle operation
/// we do for HTTPS requests.
/// As such we will be sending local credentials of current
/// User to server to authenticate requests.
/// To disable this set ProxyServer.EnableWinAuth to false
/// To disable this set ProxyServer.EnableWinAuth to false.
/// </summary>
internal async Task Handle401UnAuthorized(SessionEventArgs args)
{
......
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