Commit f4020066 authored by Honfika's avatar Honfika

stylecop fixes

parent a8497ab2
...@@ -27,7 +27,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -27,7 +27,7 @@ namespace Titanium.Web.Proxy.EventArguments
protected readonly ExceptionHandler ExceptionFunc; protected readonly ExceptionHandler ExceptionFunc;
/// <summary> /// <summary>
/// Constructor to initialize the proxy /// Initializes a new instance of the <see cref="SessionEventArgsBase" /> class.
/// </summary> /// </summary>
internal SessionEventArgsBase(int bufferSize, ProxyEndPoint endPoint, internal SessionEventArgsBase(int bufferSize, ProxyEndPoint endPoint,
CancellationTokenSource cancellationTokenSource, ExceptionHandler exceptionFunc) CancellationTokenSource cancellationTokenSource, ExceptionHandler exceptionFunc)
......
...@@ -37,6 +37,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -37,6 +37,7 @@ namespace Titanium.Web.Proxy.EventArguments
{ {
get => isHttpsConnect ?? get => isHttpsConnect ??
throw new Exception("The value of this property is known in the BeforeTunnectConnectResponse event"); throw new Exception("The value of this property is known in the BeforeTunnectConnectResponse event");
internal set => isHttpsConnect = value; internal set => isHttpsConnect = value;
} }
} }
......
...@@ -11,7 +11,7 @@ namespace Titanium.Web.Proxy.Exceptions ...@@ -11,7 +11,7 @@ namespace Titanium.Web.Proxy.Exceptions
public class ProxyAuthorizationException : ProxyException public class ProxyAuthorizationException : ProxyException
{ {
/// <summary> /// <summary>
/// Instantiate new instance. /// Initializes a new instance of the <see cref="ProxyAuthorizationException" /> class.
/// </summary> /// </summary>
/// <param name="message">Exception message.</param> /// <param name="message">Exception message.</param>
/// <param name="session">The <see cref="SessionEventArgs" /> instance containing the event data.</param> /// <param name="session">The <see cref="SessionEventArgs" /> instance containing the event data.</param>
......
...@@ -9,7 +9,7 @@ namespace Titanium.Web.Proxy.Exceptions ...@@ -9,7 +9,7 @@ namespace Titanium.Web.Proxy.Exceptions
public class ProxyConnectException : ProxyException public class ProxyConnectException : ProxyException
{ {
/// <summary> /// <summary>
/// Instantiate new instance /// Initializes a new instance of the <see cref="ProxyConnectException" /> class.
/// </summary> /// </summary>
/// <param name="message">Message for this exception</param> /// <param name="message">Message for this exception</param>
/// <param name="innerException">Associated inner exception</param> /// <param name="innerException">Associated inner exception</param>
......
...@@ -8,7 +8,8 @@ namespace Titanium.Web.Proxy.Exceptions ...@@ -8,7 +8,8 @@ namespace Titanium.Web.Proxy.Exceptions
public abstract class ProxyException : Exception public abstract class ProxyException : Exception
{ {
/// <summary> /// <summary>
/// Instantiate a new instance of this exception - must be invoked by derived classes' constructors /// Initializes a new instance of the <see cref="ProxyException" /> class.
/// - must be invoked by derived classes' constructors
/// </summary> /// </summary>
/// <param name="message">Exception message</param> /// <param name="message">Exception message</param>
protected ProxyException(string message) : base(message) protected ProxyException(string message) : base(message)
...@@ -16,7 +17,8 @@ namespace Titanium.Web.Proxy.Exceptions ...@@ -16,7 +17,8 @@ namespace Titanium.Web.Proxy.Exceptions
} }
/// <summary> /// <summary>
/// Instantiate this exception - must be invoked by derived classes' constructors /// Initializes a new instance of the <see cref="ProxyException" /> class.
/// - must be invoked by derived classes' constructors
/// </summary> /// </summary>
/// <param name="message">Excception message</param> /// <param name="message">Excception message</param>
/// <param name="innerException">Inner exception associated</param> /// <param name="innerException">Inner exception associated</param>
......
...@@ -9,7 +9,7 @@ namespace Titanium.Web.Proxy.Exceptions ...@@ -9,7 +9,7 @@ namespace Titanium.Web.Proxy.Exceptions
public class ProxyHttpException : ProxyException public class ProxyHttpException : ProxyException
{ {
/// <summary> /// <summary>
/// Instantiate new instance /// Initializes a new instance of the <see cref="ProxyHttpException" /> class.
/// </summary> /// </summary>
/// <param name="message">Message for this exception</param> /// <param name="message">Message for this exception</param>
/// <param name="innerException">Associated inner exception</param> /// <param name="innerException">Associated inner exception</param>
......
...@@ -20,7 +20,7 @@ using Titanium.Web.Proxy.Network.Tcp; ...@@ -20,7 +20,7 @@ using Titanium.Web.Proxy.Network.Tcp;
namespace Titanium.Web.Proxy namespace Titanium.Web.Proxy
{ {
partial class ProxyServer public partial class ProxyServer
{ {
/// <summary> /// <summary>
/// This is called when client is aware of proxy /// This is called when client is aware of proxy
......
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net.Security; using System.Net.Security;
using System.Security.Authentication; using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
...@@ -81,6 +82,7 @@ namespace Titanium.Web.Proxy.Extensions ...@@ -81,6 +82,7 @@ namespace Titanium.Web.Proxy.Extensions
Http2 Http2
} }
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleType", Justification = "Reviewed.")]
internal class SslClientAuthenticationOptions internal class SslClientAuthenticationOptions
{ {
internal bool AllowRenegotiation { get; set; } internal bool AllowRenegotiation { get; set; }
......
...@@ -35,7 +35,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -35,7 +35,7 @@ namespace Titanium.Web.Proxy.Helpers
if (split.Length == 2 && split[0].Trim().EqualsIgnoreCase(KnownHeaders.ContentTypeCharset)) if (split.Length == 2 && split[0].Trim().EqualsIgnoreCase(KnownHeaders.ContentTypeCharset))
{ {
string value = split[1]; string value = split[1];
if (value.Equals("x-user-defined", StringComparison.OrdinalIgnoreCase)) if (value.EqualsIgnoreCase("x-user-defined"))
{ {
continue; continue;
} }
......
...@@ -21,6 +21,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -21,6 +21,7 @@ namespace Titanium.Web.Proxy.Helpers
// get local IP addresses // get local IP addresses
var localIPs = Dns.GetHostAddresses(Dns.GetHostName()); var localIPs = Dns.GetHostAddresses(Dns.GetHostName());
// test if any host IP equals to any local IP or to localhost // test if any host IP equals to any local IP or to localhost
return localIPs.Contains(address); return localIPs.Contains(address);
} }
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Microsoft.Win32; using Microsoft.Win32;
using Titanium.Web.Proxy.Models; using Titanium.Web.Proxy.Models;
...@@ -6,7 +7,6 @@ using Titanium.Web.Proxy.Models; ...@@ -6,7 +7,6 @@ using Titanium.Web.Proxy.Models;
// Helper classes for setting system proxy settings // Helper classes for setting system proxy settings
namespace Titanium.Web.Proxy.Helpers namespace Titanium.Web.Proxy.Helpers
{ {
internal class HttpSystemProxyValue internal class HttpSystemProxyValue
{ {
internal string HostName { get; set; } internal string HostName { get; set; }
...@@ -37,6 +37,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -37,6 +37,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <summary> /// <summary>
/// Manage system proxy settings /// Manage system proxy settings
/// </summary> /// </summary>
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleType", Justification = "Reviewed.")]
internal class SystemProxyManager internal class SystemProxyManager
{ {
private const string regKeyInternetSettings = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"; private const string regKeyInternetSettings = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
......
...@@ -94,7 +94,6 @@ namespace Titanium.Web.Proxy.Http ...@@ -94,7 +94,6 @@ namespace Titanium.Web.Proxy.Http
useUpstreamProxy || isTransparent ? Request.OriginalUrl : Request.RequestUri.PathAndQuery, useUpstreamProxy || isTransparent ? Request.OriginalUrl : Request.RequestUri.PathAndQuery,
Request.HttpVersion), cancellationToken); Request.HttpVersion), cancellationToken);
// Send Authentication to Upstream proxy if needed // Send Authentication to Upstream proxy if needed
if (!isTransparent && upstreamProxy != null if (!isTransparent && upstreamProxy != null
&& ServerConnection.IsHttps == false && ServerConnection.IsHttps == false
......
...@@ -212,7 +212,7 @@ namespace Titanium.Web.Proxy.Http ...@@ -212,7 +212,7 @@ namespace Titanium.Web.Proxy.Http
{ {
string httpVersion = httpCmdSplit[2].Trim(); string httpVersion = httpCmdSplit[2].Trim();
if (string.Equals(httpVersion, "HTTP/1.0", StringComparison.OrdinalIgnoreCase)) if (httpVersion.EqualsIgnoreCase("HTTP/1.0"))
{ {
version = HttpHeader.Version10; version = HttpHeader.Version10;
} }
......
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Text; using System.Text;
using Titanium.Web.Proxy.Compression; using Titanium.Web.Proxy.Compression;
...@@ -14,7 +15,7 @@ namespace Titanium.Web.Proxy.Http ...@@ -14,7 +15,7 @@ namespace Titanium.Web.Proxy.Http
/// <summary> /// <summary>
/// Cached body content as byte array. /// Cached body content as byte array.
/// </summary> /// </summary>
protected byte[] BodyInternal; protected byte[] BodyInternal { get; private set; }
/// <summary> /// <summary>
/// Cached body as string. /// Cached body as string.
...@@ -24,7 +25,7 @@ namespace Titanium.Web.Proxy.Http ...@@ -24,7 +25,7 @@ namespace Titanium.Web.Proxy.Http
/// <summary> /// <summary>
/// Store weather the original request/response has body or not, since the user may change the parameters /// Store weather the original request/response has body or not, since the user may change the parameters
/// </summary> /// </summary>
internal bool OriginalHasBody; internal bool OriginalHasBody { get; set; }
/// <summary> /// <summary>
/// Keeps the body data after the session is finished. /// Keeps the body data after the session is finished.
...@@ -62,6 +63,7 @@ namespace Titanium.Web.Proxy.Http ...@@ -62,6 +63,7 @@ namespace Titanium.Web.Proxy.Http
return -1; return -1;
} }
set set
{ {
if (value >= 0) if (value >= 0)
...@@ -105,6 +107,7 @@ namespace Titanium.Web.Proxy.Http ...@@ -105,6 +107,7 @@ namespace Titanium.Web.Proxy.Http
string headerValue = Headers.GetHeaderValueOrNull(KnownHeaders.TransferEncoding); string headerValue = Headers.GetHeaderValueOrNull(KnownHeaders.TransferEncoding);
return headerValue != null && headerValue.ContainsIgnoreCase(KnownHeaders.TransferEncodingChunked); return headerValue != null && headerValue.ContainsIgnoreCase(KnownHeaders.TransferEncodingChunked);
} }
set set
{ {
if (value) if (value)
...@@ -135,6 +138,7 @@ namespace Titanium.Web.Proxy.Http ...@@ -135,6 +138,7 @@ namespace Titanium.Web.Proxy.Http
EnsureBodyAvailable(); EnsureBodyAvailable();
return BodyInternal; return BodyInternal;
} }
internal set internal set
{ {
BodyInternal = value; BodyInternal = value;
......
...@@ -155,7 +155,7 @@ namespace Titanium.Web.Proxy.Http ...@@ -155,7 +155,7 @@ namespace Titanium.Web.Proxy.Http
string httpVersion = httpResult[0]; string httpVersion = httpResult[0];
version = HttpHeader.Version11; version = HttpHeader.Version11;
if (string.Equals(httpVersion, "HTTP/1.0", StringComparison.OrdinalIgnoreCase)) if (httpVersion.EqualsIgnoreCase("HTTP/1.0"))
{ {
version = HttpHeader.Version10; version = HttpHeader.Version10;
} }
......
...@@ -3,9 +3,9 @@ using System.Web; ...@@ -3,9 +3,9 @@ using System.Web;
namespace Titanium.Web.Proxy.Http.Responses namespace Titanium.Web.Proxy.Http.Responses
{ {
/// <summary> /// <summary>
/// Anything other than a 200 or 302 response /// Anything other than a 200 or 302 response
/// </summary> /// </summary>
public class GenericResponse : Response public class GenericResponse : Response
{ {
/// <summary> /// <summary>
......
...@@ -8,7 +8,7 @@ namespace Titanium.Web.Proxy.Http.Responses ...@@ -8,7 +8,7 @@ namespace Titanium.Web.Proxy.Http.Responses
public sealed class RedirectResponse : Response public sealed class RedirectResponse : Response
{ {
/// <summary> /// <summary>
/// Constructor. /// Initializes a new instance of the <see cref="RedirectResponse" /> class.
/// </summary> /// </summary>
public RedirectResponse() public RedirectResponse()
{ {
......
...@@ -58,8 +58,8 @@ namespace Titanium.Web.Proxy.Network ...@@ -58,8 +58,8 @@ namespace Titanium.Web.Proxy.Network
private string rootCertificateName; private string rootCertificateName;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="CertificateManager"/> class.
/// </summary> /// </summary>
/// <param name="rootCertificateName"></param> /// <param name="rootCertificateName"></param>
/// <param name="rootCertificateIssuerName"></param> /// <param name="rootCertificateIssuerName"></param>
...@@ -242,7 +242,6 @@ namespace Titanium.Web.Proxy.Network ...@@ -242,7 +242,6 @@ namespace Titanium.Web.Proxy.Network
{ {
} }
private string GetRootCertificateDirectory() private string GetRootCertificateDirectory()
{ {
string assemblyLocation = Assembly.GetExecutingAssembly().Location; string assemblyLocation = Assembly.GetExecutingAssembly().Location;
...@@ -254,7 +253,7 @@ namespace Titanium.Web.Proxy.Network ...@@ -254,7 +253,7 @@ namespace Titanium.Web.Proxy.Network
} }
string path = Path.GetDirectoryName(assemblyLocation); string path = Path.GetDirectoryName(assemblyLocation);
if (null == path) if (path == null)
{ {
throw new NullReferenceException(); throw new NullReferenceException();
} }
...@@ -322,7 +321,6 @@ namespace Titanium.Web.Proxy.Network ...@@ -322,7 +321,6 @@ namespace Titanium.Web.Proxy.Network
/// </summary> /// </summary>
/// <param name="storeName"></param> /// <param name="storeName"></param>
/// <param name="storeLocation"></param> /// <param name="storeLocation"></param>
/// <returns></returns>
private void InstallCertificate(StoreName storeName, StoreLocation storeLocation) private void InstallCertificate(StoreName storeName, StoreLocation storeLocation)
{ {
if (RootCertificate == null) if (RootCertificate == null)
...@@ -359,7 +357,6 @@ namespace Titanium.Web.Proxy.Network ...@@ -359,7 +357,6 @@ namespace Titanium.Web.Proxy.Network
/// <param name="storeName"></param> /// <param name="storeName"></param>
/// <param name="storeLocation"></param> /// <param name="storeLocation"></param>
/// <param name="certificate"></param> /// <param name="certificate"></param>
/// <returns></returns>
private void UninstallCertificate(StoreName storeName, StoreLocation storeLocation, private void UninstallCertificate(StoreName storeName, StoreLocation storeLocation,
X509Certificate2 certificate) X509Certificate2 certificate)
{ {
...@@ -447,9 +444,9 @@ namespace Titanium.Web.Proxy.Network ...@@ -447,9 +444,9 @@ namespace Titanium.Web.Proxy.Network
{ {
certificate = new X509Certificate2(certificatePath, string.Empty, StorageFlag); certificate = new X509Certificate2(certificatePath, string.Empty, StorageFlag);
} }
// if load failed create again
catch catch
{ {
// if load failed create again
certificate = MakeCertificate(certificateName, false); certificate = MakeCertificate(certificateName, false);
} }
} }
...@@ -533,7 +530,6 @@ namespace Titanium.Web.Proxy.Network ...@@ -533,7 +530,6 @@ namespace Titanium.Web.Proxy.Network
} }
} }
/// <summary> /// <summary>
/// Stops the certificate cache clear process /// Stops the certificate cache clear process
/// </summary> /// </summary>
...@@ -780,7 +776,6 @@ namespace Titanium.Web.Proxy.Network ...@@ -780,7 +776,6 @@ namespace Titanium.Web.Proxy.Network
EnsureRootCertificate(); EnsureRootCertificate();
} }
/// <summary> /// <summary>
/// Determines whether the root certificate is trusted. /// Determines whether the root certificate is trusted.
/// </summary> /// </summary>
...@@ -866,6 +861,7 @@ namespace Titanium.Web.Proxy.Network ...@@ -866,6 +861,7 @@ namespace Titanium.Web.Proxy.Network
ErrorDialog = false, ErrorDialog = false,
WindowStyle = ProcessWindowStyle.Hidden WindowStyle = ProcessWindowStyle.Hidden
}, },
// currentUser\Personal & currentMachine\Personal // currentUser\Personal & currentMachine\Personal
new ProcessStartInfo new ProcessStartInfo
{ {
......
...@@ -65,8 +65,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security ...@@ -65,8 +65,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
// methods // methods
private void Decode(byte[] message) private void Decode(byte[] message)
{ {
//base.Decode (message);
if (message == null) if (message == null)
{ {
throw new ArgumentNullException(nameof(message)); throw new ArgumentNullException(nameof(message));
......
...@@ -19,7 +19,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security ...@@ -19,7 +19,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
/// </summary> /// </summary>
private static readonly IDictionary<Guid, State> authStates = new ConcurrentDictionary<Guid, State>(); private static readonly IDictionary<Guid, State> authStates = new ConcurrentDictionary<Guid, State>();
/// <summary> /// <summary>
/// Acquire the intial client token to send /// Acquire the intial client token to send
/// </summary> /// </summary>
...@@ -69,7 +68,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security ...@@ -69,7 +68,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
out NewContextAttributes, out NewContextAttributes,
out NewLifeTime); out NewLifeTime);
if (result != IntermediateResult) if (result != IntermediateResult)
{ {
return null; return null;
...@@ -123,7 +121,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security ...@@ -123,7 +121,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
out NewContextAttributes, out NewContextAttributes,
out NewLifeTime); out NewLifeTime);
if (result != SuccessfulResult) if (result != SuccessfulResult)
{ {
return null; return null;
...@@ -173,18 +170,16 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security ...@@ -173,18 +170,16 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
if (expectedAuthState == State.WinAuthState.UNAUTHORIZED) if (expectedAuthState == State.WinAuthState.UNAUTHORIZED)
{ {
return stateExists == false || return !stateExists ||
state.AuthState == State.WinAuthState.UNAUTHORIZED || state.AuthState == State.WinAuthState.UNAUTHORIZED ||
state.AuthState == state.AuthState == State.WinAuthState.AUTHORIZED; // Server may require re-authentication on an open connection
State.WinAuthState.AUTHORIZED; // Server may require re-authentication on an open connection
} }
if (expectedAuthState == State.WinAuthState.INITIAL_TOKEN) if (expectedAuthState == State.WinAuthState.INITIAL_TOKEN)
{ {
return stateExists && return stateExists &&
(state.AuthState == State.WinAuthState.INITIAL_TOKEN || (state.AuthState == State.WinAuthState.INITIAL_TOKEN ||
state.AuthState == State.WinAuthState.AUTHORIZED state.AuthState == State.WinAuthState.AUTHORIZED); // Server may require re-authentication on an open connection
); // Server may require re-authentication on an open connection
} }
throw new Exception("Unsupported validation of WinAuthState"); throw new Exception("Unsupported validation of WinAuthState");
......
...@@ -24,7 +24,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth ...@@ -24,7 +24,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth
return string.Concat(" ", Convert.ToBase64String(tokenBytes)); return string.Concat(" ", Convert.ToBase64String(tokenBytes));
} }
/// <summary> /// <summary>
/// Get the final token given the server challenge token /// Get the final token given the server challenge token
/// </summary> /// </summary>
......
...@@ -9,6 +9,7 @@ using System.Threading; ...@@ -9,6 +9,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using StreamExtended.Network; using StreamExtended.Network;
using Titanium.Web.Proxy.EventArguments; using Titanium.Web.Proxy.EventArguments;
using Titanium.Web.Proxy.Extensions;
using Titanium.Web.Proxy.Helpers; using Titanium.Web.Proxy.Helpers;
using Titanium.Web.Proxy.Helpers.WinHttp; using Titanium.Web.Proxy.Helpers.WinHttp;
using Titanium.Web.Proxy.Models; using Titanium.Web.Proxy.Models;
...@@ -25,7 +26,7 @@ namespace Titanium.Web.Proxy ...@@ -25,7 +26,7 @@ namespace Titanium.Web.Proxy
public partial class ProxyServer : IDisposable public partial class ProxyServer : IDisposable
{ {
/// <summary> /// <summary>
/// HTTP & HTTPS scheme shorthands. /// HTTP &amp; HTTPS scheme shorthands.
/// </summary> /// </summary>
internal static readonly string UriSchemeHttp = Uri.UriSchemeHttp; internal static readonly string UriSchemeHttp = Uri.UriSchemeHttp;
...@@ -171,7 +172,6 @@ namespace Titanium.Web.Proxy ...@@ -171,7 +172,6 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public string ProxyRealm { get; set; } = "TitaniumProxy"; public string ProxyRealm { get; set; } = "TitaniumProxy";
/// <summary> /// <summary>
/// List of supported Ssl versions. /// List of supported Ssl versions.
/// </summary> /// </summary>
...@@ -181,7 +181,6 @@ namespace Titanium.Web.Proxy ...@@ -181,7 +181,6 @@ namespace Titanium.Web.Proxy
#endif #endif
SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12; SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12;
/// <summary> /// <summary>
/// Manages certificates used by this proxy. /// Manages certificates used by this proxy.
/// </summary> /// </summary>
...@@ -483,7 +482,7 @@ namespace Titanium.Web.Proxy ...@@ -483,7 +482,7 @@ namespace Titanium.Web.Proxy
foreach (var proxy in proxyInfo.Proxies.Values) foreach (var proxy in proxyInfo.Proxies.Values)
{ {
if ((proxy.HostName == "127.0.0.1" if ((proxy.HostName == "127.0.0.1"
|| proxy.HostName.Equals("localhost", StringComparison.OrdinalIgnoreCase)) || proxy.HostName.EqualsIgnoreCase("localhost"))
&& ProxyEndPoints.Any(x => x.Port == proxy.Port)) && ProxyEndPoints.Any(x => x.Port == proxy.Port))
{ {
protocolToRemove |= proxy.ProtocolType; protocolToRemove |= proxy.ProtocolType;
......
...@@ -17,7 +17,7 @@ namespace Titanium.Web.Proxy ...@@ -17,7 +17,7 @@ namespace Titanium.Web.Proxy
/// <summary> /// <summary>
/// Handle the request /// Handle the request
/// </summary> /// </summary>
partial class ProxyServer public partial class ProxyServer
{ {
private static readonly Regex uriSchemeRegex = private static readonly Regex uriSchemeRegex =
new Regex("^[a-z]*://", RegexOptions.IgnoreCase | RegexOptions.Compiled); new Regex("^[a-z]*://", RegexOptions.IgnoreCase | RegexOptions.Compiled);
...@@ -40,8 +40,6 @@ namespace Titanium.Web.Proxy ...@@ -40,8 +40,6 @@ namespace Titanium.Web.Proxy
/// explicit endpoint. /// explicit endpoint.
/// </param> /// </param>
/// <param name="connectRequest">The 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, TcpClientConnection clientConnection, private async Task HandleHttpSessionRequest(ProxyEndPoint endPoint, TcpClientConnection clientConnection,
CustomBufferedStream clientStream, HttpResponseWriter clientStreamWriter, CustomBufferedStream clientStream, HttpResponseWriter clientStreamWriter,
CancellationTokenSource cancellationTokenSource, string httpsConnectHostname, ConnectRequest connectRequest) CancellationTokenSource cancellationTokenSource, string httpsConnectHostname, ConnectRequest connectRequest)
...@@ -171,10 +169,9 @@ namespace Titanium.Web.Proxy ...@@ -171,10 +169,9 @@ namespace Titanium.Web.Proxy
// create a new connection if hostname/upstream end point changes // create a new connection if hostname/upstream end point changes
if (serverConnection != null if (serverConnection != null
&& (!serverConnection.HostName.Equals(request.RequestUri.Host, && (!serverConnection.HostName.EqualsIgnoreCase(request.RequestUri.Host)
StringComparison.OrdinalIgnoreCase) || args.WebSession.UpStreamEndPoint?.Equals(serverConnection.UpStreamEndPoint) ==
|| args.WebSession.UpStreamEndPoint != null false))
&& !args.WebSession.UpStreamEndPoint.Equals(serverConnection.UpStreamEndPoint)))
{ {
serverConnection.Dispose(); serverConnection.Dispose();
serverConnection = null; serverConnection = null;
......
...@@ -11,7 +11,7 @@ namespace Titanium.Web.Proxy ...@@ -11,7 +11,7 @@ namespace Titanium.Web.Proxy
/// <summary> /// <summary>
/// Handle the response from server. /// Handle the response from server.
/// </summary> /// </summary>
partial class ProxyServer public partial class ProxyServer
{ {
/// <summary> /// <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.
...@@ -23,6 +23,7 @@ namespace Titanium.Web.Proxy ...@@ -23,6 +23,7 @@ namespace Titanium.Web.Proxy
try try
{ {
var cancellationToken = args.CancellationTokenSource.Token; var cancellationToken = args.CancellationTokenSource.Token;
// read response & headers from server // read response & headers from server
await args.WebSession.ReceiveResponse(cancellationToken); await args.WebSession.ReceiveResponse(cancellationToken);
......
<StyleCopSettings Version="105">
<Analyzers>
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
<Rules>
<Rule Name="FileMustHaveHeader">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParameterDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementReturnValueMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementReturnValueDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PropertySummaryDocumentationMustMatchAccessors">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ConstructorSummaryDocumentationMustBeginWithStandardText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="EnumerationItemsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationTextMustContainWhitespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustShowCopyright">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParametersMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PartialElementsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules">
<Rules>
<Rule Name="PrefixLocalCallsWithThis">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ParametersMustBeOnSameLineOrSeparateLines">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PrefixCallsCorrectly">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.NamingRules">
<Rules>
<Rule Name="ElementMustBeginWithUpperCaseLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="StaticReadonlyFieldsMustBeginWithUpperCaseLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ConstFieldNamesMustBeginWithUpperCaseLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FieldNamesMustNotUseHungarianNotation">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FieldNamesMustBeginWithLowerCaseLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.OrderingRules">
<Rules>
<Rule Name="UsingDirectivesMustBePlacedWithinNamespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementsMustBeOrderedByAccess">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="StaticElementsMustAppearBeforeInstanceElements">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementsMustAppearInTheCorrectOrder">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ConstantsMustAppearBeforeFields">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
</Analyzers>
</StyleCopSettings>
\ No newline at end of file
...@@ -17,7 +17,7 @@ using Titanium.Web.Proxy.Network.Tcp; ...@@ -17,7 +17,7 @@ using Titanium.Web.Proxy.Network.Tcp;
namespace Titanium.Web.Proxy namespace Titanium.Web.Proxy
{ {
partial class ProxyServer public partial class ProxyServer
{ {
/// <summary> /// <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).
...@@ -115,7 +115,7 @@ namespace Titanium.Web.Proxy ...@@ -115,7 +115,7 @@ namespace Titanium.Web.Proxy
} }
} }
//var serverHelloInfo = await SslTools.PeekServerHello(serverStream); ////var serverHelloInfo = await SslTools.PeekServerHello(serverStream);
await TcpHelper.SendRaw(clientStream, serverStream, BufferSize, await TcpHelper.SendRaw(clientStream, serverStream, BufferSize,
null, null, cancellationTokenSource, ExceptionFunc); null, null, cancellationTokenSource, ExceptionFunc);
......
...@@ -124,9 +124,10 @@ namespace Titanium.Web.Proxy ...@@ -124,9 +124,10 @@ namespace Titanium.Web.Proxy
request.ContentLength = 0; request.ContentLength = 0;
} }
} }
// challenge value will start with any of the scheme selected
else else
{ {
// challenge value will start with any of the scheme selected
scheme = authSchemes.First(x => scheme = authSchemes.First(x =>
authHeader.Value.StartsWith(x, StringComparison.OrdinalIgnoreCase) && authHeader.Value.StartsWith(x, StringComparison.OrdinalIgnoreCase) &&
authHeader.Value.Length > x.Length + 1); authHeader.Value.Length > x.Length + 1);
......
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