Commit e2c392f9 authored by Honfika's avatar Honfika

Format code

parent 711fc5e5
...@@ -48,7 +48,6 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -48,7 +48,6 @@ namespace Titanium.Web.Proxy.EventArguments
/// </summary> /// </summary>
public Guid Id => WebSession.RequestId; public Guid Id => WebSession.RequestId;
/// <summary> /// <summary>
/// Should we send the request again /// Should we send the request again
/// </summary> /// </summary>
...@@ -59,8 +58,8 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -59,8 +58,8 @@ namespace Titanium.Web.Proxy.EventArguments
{ {
if (WebSession.Response.ResponseStatusCode == null) if (WebSession.Response.ResponseStatusCode == null)
{ {
throw new Exception("Response status code is null. Cannot request again a request " throw new Exception("Response status code is null. Cannot request again a request "
+ "which was never send to server."); + "which was never send to server.");
} }
reRequest = value; reRequest = value;
......
...@@ -359,7 +359,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -359,7 +359,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if(!disposed) if (!disposed)
{ {
disposed = true; disposed = true;
baseStream.Dispose(); baseStream.Dispose();
...@@ -367,7 +367,6 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -367,7 +367,6 @@ namespace Titanium.Web.Proxy.Helpers
streamBuffer = null; streamBuffer = null;
readCallback = null; readCallback = null;
} }
} }
/// <summary> /// <summary>
......
...@@ -68,7 +68,6 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -68,7 +68,6 @@ namespace Titanium.Web.Proxy.Helpers
int idx = hostname.IndexOf(ProxyConstants.DotSplit); int idx = hostname.IndexOf(ProxyConstants.DotSplit);
var rootDomain = hostname.Substring(idx + 1); var rootDomain = hostname.Substring(idx + 1);
return "*." + rootDomain; return "*." + rootDomain;
} }
//return as it is //return as it is
......
...@@ -36,7 +36,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -36,7 +36,7 @@ namespace Titanium.Web.Proxy.Helpers
if (proxyServer != null) if (proxyServer != null)
{ {
Proxies = GetSystemProxyValues(proxyServer).ToDictionary(x=>x.ProtocolType); Proxies = GetSystemProxyValues(proxyServer).ToDictionary(x => x.ProtocolType);
} }
if (proxyOverride != null) if (proxyOverride != null)
......
...@@ -12,8 +12,8 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -12,8 +12,8 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private static readonly Lazy<bool> isRunningOnMono private static readonly Lazy<bool> isRunningOnMono
= new Lazy<bool>(()=> Type.GetType("Mono.Runtime") != null); = new Lazy<bool>(() => Type.GetType("Mono.Runtime") != null);
/// <summary> /// <summary>
/// Is running on Mono? /// Is running on Mono?
/// </summary> /// </summary>
......
...@@ -16,4 +16,4 @@ namespace Titanium.Web.Proxy.Helpers.WinHttp ...@@ -16,4 +16,4 @@ namespace Titanium.Web.Proxy.Helpers.WinHttp
public override bool IsInvalid => handle == IntPtr.Zero; public override bool IsInvalid => handle == IntPtr.Zero;
} }
} }
\ No newline at end of file
...@@ -21,7 +21,7 @@ namespace Titanium.Web.Proxy.Helpers.WinHttp ...@@ -21,7 +21,7 @@ namespace Titanium.Web.Proxy.Helpers.WinHttp
public bool BypassLoopback { get; internal set; } public bool BypassLoopback { get; internal set; }
public bool BypassOnLocal { get; internal set; } public bool BypassOnLocal { get; internal set; }
public Uri AutomaticConfigurationScript { get; internal set; } public Uri AutomaticConfigurationScript { get; internal set; }
public bool AutomaticallyDetectSettings { get; internal set; } public bool AutomaticallyDetectSettings { get; internal set; }
...@@ -214,7 +214,7 @@ namespace Titanium.Web.Proxy.Helpers.WinHttp ...@@ -214,7 +214,7 @@ namespace Titanium.Web.Proxy.Helpers.WinHttp
if (!WinHttpGetProxyForUrl(destination.ToString(), ref autoProxyOptions, out proxyListString)) if (!WinHttpGetProxyForUrl(destination.ToString(), ref autoProxyOptions, out proxyListString))
{ {
num = GetLastWin32Error(); num = GetLastWin32Error();
if (num == (int)NativeMethods.WinHttp.ErrorCodes.LoginFailure && Credentials != null) if (num == (int)NativeMethods.WinHttp.ErrorCodes.LoginFailure && Credentials != null)
{ {
autoProxyOptions.AutoLogonIfChallenged = true; autoProxyOptions.AutoLogonIfChallenged = true;
...@@ -329,4 +329,4 @@ namespace Titanium.Web.Proxy.Helpers.WinHttp ...@@ -329,4 +329,4 @@ namespace Titanium.Web.Proxy.Helpers.WinHttp
Completed, Completed,
} }
} }
} }
\ No newline at end of file
...@@ -84,8 +84,8 @@ namespace Titanium.Web.Proxy.Http ...@@ -84,8 +84,8 @@ namespace Titanium.Web.Proxy.Http
//Send Authentication to Upstream proxy if needed //Send Authentication to Upstream proxy if needed
if (ServerConnection.UpStreamHttpProxy != null if (ServerConnection.UpStreamHttpProxy != null
&& ServerConnection.IsHttps == false && ServerConnection.IsHttps == false
&& !string.IsNullOrEmpty(ServerConnection.UpStreamHttpProxy.UserName) && !string.IsNullOrEmpty(ServerConnection.UpStreamHttpProxy.UserName)
&& ServerConnection.UpStreamHttpProxy.Password != null) && ServerConnection.UpStreamHttpProxy.Password != null)
{ {
......
...@@ -431,12 +431,11 @@ namespace Titanium.Web.Proxy.Http ...@@ -431,12 +431,11 @@ namespace Titanium.Web.Proxy.Http
RequestHeaders.Remove(header.Name); RequestHeaders.Remove(header.Name);
return true; return true;
} }
} }
else if (NonUniqueRequestHeaders.ContainsKey(header.Name)) else if (NonUniqueRequestHeaders.ContainsKey(header.Name))
{ {
if (NonUniqueRequestHeaders[header.Name] if (NonUniqueRequestHeaders[header.Name]
.RemoveAll(x => x.Equals(header)) > 0) .RemoveAll(x => x.Equals(header)) > 0)
{ {
return true; return true;
} }
...@@ -460,7 +459,5 @@ namespace Titanium.Web.Proxy.Http ...@@ -460,7 +459,5 @@ namespace Titanium.Web.Proxy.Http
RequestBody = null; RequestBody = null;
RequestBody = null; RequestBody = null;
} }
} }
} }
...@@ -249,7 +249,7 @@ namespace Titanium.Web.Proxy.Http ...@@ -249,7 +249,7 @@ namespace Titanium.Web.Proxy.Http
/// <returns></returns> /// <returns></returns>
public bool HeaderExists(string name) public bool HeaderExists(string name)
{ {
if(ResponseHeaders.ContainsKey(name) if (ResponseHeaders.ContainsKey(name)
|| NonUniqueResponseHeaders.ContainsKey(name)) || NonUniqueResponseHeaders.ContainsKey(name))
{ {
return true; return true;
...@@ -336,7 +336,7 @@ namespace Titanium.Web.Proxy.Http ...@@ -336,7 +336,7 @@ namespace Titanium.Web.Proxy.Http
/// False if no header exists with given name</returns> /// False if no header exists with given name</returns>
public bool RemoveHeader(string headerName) public bool RemoveHeader(string headerName)
{ {
if(ResponseHeaders.ContainsKey(headerName)) if (ResponseHeaders.ContainsKey(headerName))
{ {
ResponseHeaders.Remove(headerName); ResponseHeaders.Remove(headerName);
return true; return true;
...@@ -363,12 +363,11 @@ namespace Titanium.Web.Proxy.Http ...@@ -363,12 +363,11 @@ namespace Titanium.Web.Proxy.Http
ResponseHeaders.Remove(header.Name); ResponseHeaders.Remove(header.Name);
return true; return true;
} }
} }
else if (NonUniqueResponseHeaders.ContainsKey(header.Name)) else if (NonUniqueResponseHeaders.ContainsKey(header.Name))
{ {
if (NonUniqueResponseHeaders[header.Name] if (NonUniqueResponseHeaders[header.Name]
.RemoveAll(x => x.Equals(header)) > 0) .RemoveAll(x => x.Equals(header)) > 0)
{ {
return true; return true;
} }
......
...@@ -53,7 +53,6 @@ namespace Titanium.Web.Proxy.Models ...@@ -53,7 +53,6 @@ namespace Titanium.Web.Proxy.Models
public bool IpV6Enabled => Equals(IpAddress, IPAddress.IPv6Any) public bool IpV6Enabled => Equals(IpAddress, IPAddress.IPv6Any)
|| Equals(IpAddress, IPAddress.IPv6Loopback) || Equals(IpAddress, IPAddress.IPv6Loopback)
|| Equals(IpAddress, IPAddress.IPv6None); || Equals(IpAddress, IPAddress.IPv6None);
} }
/// <summary> /// <summary>
......
...@@ -351,7 +351,7 @@ namespace Titanium.Web.Proxy.Network ...@@ -351,7 +351,7 @@ namespace Titanium.Web.Proxy.Network
x509Store.Close(); x509Store.Close();
} }
} }
/// <summary> /// <summary>
/// Create an SSL certificate /// Create an SSL certificate
/// </summary> /// </summary>
......
...@@ -34,11 +34,11 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -34,11 +34,11 @@ namespace Titanium.Web.Proxy.Network.Tcp
bool isHttps, bool isHttps,
ExternalProxy externalHttpProxy, ExternalProxy externalHttpsProxy) ExternalProxy externalHttpProxy, ExternalProxy externalHttpsProxy)
{ {
bool useHttpProxy = false; bool useHttpProxy = false;
//check if external proxy is set for HTTP //check if external proxy is set for HTTP
if (!isHttps && externalHttpProxy != null if (!isHttps && externalHttpProxy != null
&& !(externalHttpProxy.HostName == remoteHostName && !(externalHttpProxy.HostName == remoteHostName
&& externalHttpProxy.Port == remotePort)) && externalHttpProxy.Port == remotePort))
{ {
useHttpProxy = true; useHttpProxy = true;
...@@ -53,8 +53,8 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -53,8 +53,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
bool useHttpsProxy = false; bool useHttpsProxy = false;
//check if external proxy is set for HTTPS //check if external proxy is set for HTTPS
if (isHttps && externalHttpsProxy != null if (isHttps && externalHttpsProxy != null
&& !(externalHttpsProxy.HostName == remoteHostName && !(externalHttpsProxy.HostName == remoteHostName
&& externalHttpsProxy.Port == remotePort)) && externalHttpsProxy.Port == remotePort))
{ {
useHttpsProxy = true; useHttpsProxy = true;
......
...@@ -6,25 +6,30 @@ ...@@ -6,25 +6,30 @@
internal class Common internal class Common
{ {
#region Private constants #region Private constants
private const int ISC_REQ_REPLAY_DETECT = 0x00000004; private const int ISC_REQ_REPLAY_DETECT = 0x00000004;
private const int ISC_REQ_SEQUENCE_DETECT = 0x00000008; private const int ISC_REQ_SEQUENCE_DETECT = 0x00000008;
private const int ISC_REQ_CONFIDENTIALITY = 0x00000010; private const int ISC_REQ_CONFIDENTIALITY = 0x00000010;
private const int ISC_REQ_CONNECTION = 0x00000800; private const int ISC_REQ_CONNECTION = 0x00000800;
#endregion #endregion
internal static uint NewContextAttributes = 0; internal static uint NewContextAttributes = 0;
internal static SecurityInteger NewLifeTime = new SecurityInteger(0); internal static SecurityInteger NewLifeTime = new SecurityInteger(0);
#region internal constants #region internal constants
internal const int StandardContextAttributes = ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_CONNECTION; internal const int StandardContextAttributes = ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_CONNECTION;
internal const int SecurityNativeDataRepresentation = 0x10; internal const int SecurityNativeDataRepresentation = 0x10;
internal const int MaximumTokenSize = 12288; internal const int MaximumTokenSize = 12288;
internal const int SecurityCredentialsOutbound = 2; internal const int SecurityCredentialsOutbound = 2;
internal const int SuccessfulResult = 0; internal const int SuccessfulResult = 0;
internal const int IntermediateResult = 0x90312; internal const int IntermediateResult = 0x90312;
#endregion #endregion
#region internal enumerations #region internal enumerations
internal enum SecurityBufferType internal enum SecurityBufferType
{ {
SECBUFFER_VERSION = 0, SECBUFFER_VERSION = 0,
...@@ -38,22 +43,31 @@ ...@@ -38,22 +43,31 @@
{ {
// The client sets this flag to indicate that it supports Unicode strings. // The client sets this flag to indicate that it supports Unicode strings.
NegotiateUnicode = 0x00000001, NegotiateUnicode = 0x00000001,
// This is set to indicate that the client supports OEM strings. // This is set to indicate that the client supports OEM strings.
NegotiateOem = 0x00000002, NegotiateOem = 0x00000002,
// This requests that the server send the authentication target with the Type 2 reply. // This requests that the server send the authentication target with the Type 2 reply.
RequestTarget = 0x00000004, RequestTarget = 0x00000004,
// Indicates that NTLM authentication is supported. // Indicates that NTLM authentication is supported.
NegotiateNtlm = 0x00000200, NegotiateNtlm = 0x00000200,
// When set, the client will send with the message the name of the domain in which the workstation has membership. // When set, the client will send with the message the name of the domain in which the workstation has membership.
NegotiateDomainSupplied = 0x00001000, NegotiateDomainSupplied = 0x00001000,
// Indicates that the client is sending its workstation name with the message. // Indicates that the client is sending its workstation name with the message.
NegotiateWorkstationSupplied = 0x00002000, NegotiateWorkstationSupplied = 0x00002000,
// Indicates that communication between the client and server after authentication should carry a "dummy" signature. // Indicates that communication between the client and server after authentication should carry a "dummy" signature.
NegotiateAlwaysSign = 0x00008000, NegotiateAlwaysSign = 0x00008000,
// Indicates that this client supports the NTLM2 signing and sealing scheme; if negotiated, this can also affect the response calculations. // Indicates that this client supports the NTLM2 signing and sealing scheme; if negotiated, this can also affect the response calculations.
NegotiateNtlm2Key = 0x00080000, NegotiateNtlm2Key = 0x00080000,
// Indicates that this client supports strong (128-bit) encryption. // Indicates that this client supports strong (128-bit) encryption.
Negotiate128 = 0x20000000, Negotiate128 = 0x20000000,
// Indicates that this client supports medium (56-bit) encryption. // Indicates that this client supports medium (56-bit) encryption.
Negotiate56 = (unchecked((int)0x80000000)) Negotiate56 = (unchecked((int)0x80000000))
} }
...@@ -74,9 +88,11 @@ ...@@ -74,9 +88,11 @@
/* Use NTLMv2 only. */ /* Use NTLMv2 only. */
NTLMv2_only, NTLMv2_only,
} }
#endregion #endregion
#region internal structures #region internal structures
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct SecurityHandle internal struct SecurityHandle
{ {
...@@ -102,6 +118,7 @@ ...@@ -102,6 +118,7 @@
{ {
internal uint LowPart; internal uint LowPart;
internal int HighPart; internal int HighPart;
internal SecurityInteger(int dummy) internal SecurityInteger(int dummy)
{ {
LowPart = 0; LowPart = 0;
...@@ -152,7 +169,6 @@ ...@@ -152,7 +169,6 @@
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct SecurityBufferDesciption : IDisposable internal struct SecurityBufferDesciption : IDisposable
{ {
internal int ulVersion; internal int ulVersion;
internal int cBuffers; internal int cBuffers;
internal IntPtr pBuffers; //Point to SecBuffer internal IntPtr pBuffers; //Point to SecBuffer
...@@ -260,6 +276,7 @@ ...@@ -260,6 +276,7 @@
return (buffer); return (buffer);
} }
} }
#endregion #endregion
} }
} }
...@@ -33,46 +33,38 @@ ...@@ -33,46 +33,38 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
namespace Titanium.Web.Proxy.Network.WinAuth.Security namespace Titanium.Web.Proxy.Network.WinAuth.Security
{ {
using System; using System;
using System.Text; using System.Text;
internal class Message internal class Message
{ {
static private readonly byte[] header = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00 }; static private readonly byte[] header = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00 };
internal Message (byte[] message) internal Message(byte[] message)
{
type = 3;
Decode (message);
}
/// <summary>
/// Domain name
/// </summary>
internal string Domain
{ {
get; type = 3;
private set; Decode(message);
} }
/// <summary>
/// Domain name
/// </summary>
internal string Domain { get; private set; }
/// <summary> /// <summary>
/// Username /// Username
/// </summary> /// </summary>
internal string Username internal string Username { get; private set; }
{
get;
private set;
}
private readonly int type; private readonly int type;
internal Common.NtlmFlags Flags { get; set; } internal Common.NtlmFlags Flags { get; set; }
// methods // methods
private void Decode (byte[] message) private void Decode(byte[] message)
{ {
//base.Decode (message); //base.Decode (message);
if (message == null) if (message == null)
...@@ -90,11 +82,11 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security ...@@ -90,11 +82,11 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
throw new ArgumentException(msg, "message"); throw new ArgumentException(msg, "message");
} }
if (LittleEndian.ToUInt16 (message, 56) != message.Length) if (LittleEndian.ToUInt16(message, 56) != message.Length)
{ {
string msg = "Invalid Type3 message length."; string msg = "Invalid Type3 message length.";
throw new ArgumentException (msg, "message"); throw new ArgumentException(msg, "message");
} }
if (message.Length >= 64) if (message.Length >= 64)
{ {
...@@ -104,26 +96,26 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security ...@@ -104,26 +96,26 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
{ {
Flags = (Common.NtlmFlags)0x8201; Flags = (Common.NtlmFlags)0x8201;
} }
int domLen = LittleEndian.ToUInt16 (message, 28);
int domOff = LittleEndian.ToUInt16 (message, 32);
Domain = DecodeString (message, domOff, domLen); int domLen = LittleEndian.ToUInt16(message, 28);
int domOff = LittleEndian.ToUInt16(message, 32);
int userLen = LittleEndian.ToUInt16 (message, 36); Domain = DecodeString(message, domOff, domLen);
int userOff = LittleEndian.ToUInt16 (message, 40);
Username = DecodeString (message, userOff, userLen); int userLen = LittleEndian.ToUInt16(message, 36);
} int userOff = LittleEndian.ToUInt16(message, 40);
Username = DecodeString(message, userOff, userLen);
}
string DecodeString (byte[] buffer, int offset, int len) string DecodeString(byte[] buffer, int offset, int len)
{ {
if ((Flags & Common.NtlmFlags.NegotiateUnicode) != 0) if ((Flags & Common.NtlmFlags.NegotiateUnicode) != 0)
{ {
return Encoding.Unicode.GetString(buffer, offset, len); return Encoding.Unicode.GetString(buffer, offset, len);
} }
return Encoding.ASCII.GetString(buffer, offset, len); return Encoding.ASCII.GetString(buffer, offset, len);
} }
protected bool CheckHeader(byte[] message) protected bool CheckHeader(byte[] message)
{ {
...@@ -134,6 +126,5 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security ...@@ -134,6 +126,5 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
} }
return (LittleEndian.ToUInt32(message, 8) == type); return (LittleEndian.ToUInt32(message, 8) == type);
} }
} }
} }
...@@ -216,7 +216,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security ...@@ -216,7 +216,6 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
ref SecurityHandle phCredential, //SecHandle //PCtxtHandle ref ref SecurityHandle phCredential, //SecHandle //PCtxtHandle ref
ref SecurityInteger ptsExpiry); //PTimeStamp //TimeStamp ref ref SecurityInteger ptsExpiry); //PTimeStamp //TimeStamp ref
#endregion #endregion
} }
} }
...@@ -18,11 +18,11 @@ namespace Titanium.Web.Proxy.Network.WinAuth ...@@ -18,11 +18,11 @@ namespace Titanium.Web.Proxy.Network.WinAuth
/// <param name="authScheme"></param> /// <param name="authScheme"></param>
/// <param name="requestId"></param> /// <param name="requestId"></param>
/// <returns></returns> /// <returns></returns>
public static string GetInitialAuthToken(string serverHostname, public static string GetInitialAuthToken(string serverHostname,
string authScheme, Guid requestId) string authScheme, Guid requestId)
{ {
var tokenBytes = WinAuthEndPoint.AcquireInitialSecurityToken(serverHostname, authScheme, requestId); var tokenBytes = WinAuthEndPoint.AcquireInitialSecurityToken(serverHostname, authScheme, requestId);
return string.Concat(" ", Convert.ToBase64String(tokenBytes)); return string.Concat(" ", Convert.ToBase64String(tokenBytes));
} }
...@@ -33,7 +33,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth ...@@ -33,7 +33,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth
/// <param name="serverToken"></param> /// <param name="serverToken"></param>
/// <param name="requestId"></param> /// <param name="requestId"></param>
/// <returns></returns> /// <returns></returns>
public static string GetFinalAuthToken(string serverHostname, public static string GetFinalAuthToken(string serverHostname,
string serverToken, Guid requestId) string serverToken, Guid requestId)
{ {
var tokenBytes = WinAuthEndPoint.AcquireFinalSecurityToken(serverHostname, var tokenBytes = WinAuthEndPoint.AcquireFinalSecurityToken(serverHostname,
...@@ -41,6 +41,5 @@ namespace Titanium.Web.Proxy.Network.WinAuth ...@@ -41,6 +41,5 @@ namespace Titanium.Web.Proxy.Network.WinAuth
return string.Concat(" ", Convert.ToBase64String(tokenBytes)); return string.Concat(" ", Convert.ToBase64String(tokenBytes));
} }
} }
} }
...@@ -290,7 +290,7 @@ namespace Titanium.Web.Proxy ...@@ -290,7 +290,7 @@ namespace Titanium.Web.Proxy
{ {
systemProxySettingsManager = new SystemProxyManager(); systemProxySettingsManager = new SystemProxyManager();
} }
CertificateManager = new CertificateManager(ExceptionFunc); CertificateManager = new CertificateManager(ExceptionFunc);
if (rootCertificateName != null) if (rootCertificateName != null)
{ {
...@@ -409,7 +409,9 @@ namespace Titanium.Web.Proxy ...@@ -409,7 +409,9 @@ namespace Titanium.Web.Proxy
systemProxySettingsManager.SetProxy( systemProxySettingsManager.SetProxy(
Equals(endPoint.IpAddress, IPAddress.Any) | Equals(endPoint.IpAddress, IPAddress.Any) |
Equals(endPoint.IpAddress, IPAddress.Loopback) ? "127.0.0.1" : endPoint.IpAddress.ToString(), Equals(endPoint.IpAddress, IPAddress.Loopback)
? "127.0.0.1"
: endPoint.IpAddress.ToString(),
endPoint.Port, endPoint.Port,
protocolType); protocolType);
...@@ -521,7 +523,7 @@ namespace Titanium.Web.Proxy ...@@ -521,7 +523,7 @@ namespace Titanium.Web.Proxy
} }
} }
if (ForwardToUpstreamGateway if (ForwardToUpstreamGateway
&& GetCustomUpStreamHttpProxyFunc == null && GetCustomUpStreamHttpsProxyFunc == null && GetCustomUpStreamHttpProxyFunc == null && GetCustomUpStreamHttpsProxyFunc == null
&& systemProxySettingsManager != null) && systemProxySettingsManager != null)
{ {
......
...@@ -88,7 +88,7 @@ namespace Titanium.Web.Proxy ...@@ -88,7 +88,7 @@ namespace Titanium.Web.Proxy
List<HttpHeader> connectRequestHeaders = null; List<HttpHeader> connectRequestHeaders = null;
//Client wants to create a secure tcp tunnel (its a HTTPS request) //Client wants to create a secure tcp tunnel (its a HTTPS request)
if (httpVerb == "CONNECT" && !excluded if (httpVerb == "CONNECT" && !excluded
&& endPoint.RemoteHttpsPorts.Contains(httpRemoteUri.Port)) && endPoint.RemoteHttpsPorts.Contains(httpRemoteUri.Port))
{ {
httpRemoteUri = new Uri("https://" + httpCmdSplit[1]); httpRemoteUri = new Uri("https://" + httpCmdSplit[1]);
...@@ -380,7 +380,7 @@ namespace Titanium.Web.Proxy ...@@ -380,7 +380,7 @@ namespace Titanium.Web.Proxy
args.Dispose(); args.Dispose();
break; break;
} }
//if connection is closing exit //if connection is closing exit
if (args.WebSession.Response.ResponseKeepAlive == false) if (args.WebSession.Response.ResponseKeepAlive == false)
{ {
......
...@@ -32,13 +32,13 @@ namespace Titanium.Web.Proxy ...@@ -32,13 +32,13 @@ namespace Titanium.Web.Proxy
await args.WebSession.ReceiveResponse(); await args.WebSession.ReceiveResponse();
//check for windows authentication //check for windows authentication
if(EnableWinAuth if (EnableWinAuth
&& !RunTime.IsRunningOnMono && !RunTime.IsRunningOnMono
&& args.WebSession.Response.ResponseStatusCode == "401") && args.WebSession.Response.ResponseStatusCode == "401")
{ {
var disposed = await Handle401UnAuthorized(args); var disposed = await Handle401UnAuthorized(args);
if(disposed) if (disposed)
{ {
return true; return true;
} }
......
...@@ -115,7 +115,6 @@ namespace Titanium.Web.Proxy ...@@ -115,7 +115,6 @@ namespace Titanium.Web.Proxy
{ {
args.WebSession.Request.ContentLength = 0; args.WebSession.Request.ContentLength = 0;
} }
} }
//challenge value will start with any of the scheme selected //challenge value will start with any of the scheme selected
else else
...@@ -136,7 +135,6 @@ namespace Titanium.Web.Proxy ...@@ -136,7 +135,6 @@ namespace Titanium.Web.Proxy
args.WebSession.Request.ContentLength args.WebSession.Request.ContentLength
= args.WebSession.Request.RequestBody.Length; = args.WebSession.Request.RequestBody.Length;
} }
} }
//Need to revisit this. //Need to revisit this.
...@@ -154,6 +152,5 @@ namespace Titanium.Web.Proxy ...@@ -154,6 +152,5 @@ namespace Titanium.Web.Proxy
return false; return false;
} }
} }
} }
\ No newline at end of file
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