Commit 77d9258f authored by Honfika's avatar Honfika

inconsistent naming fixes

parent 6996456c
...@@ -32,11 +32,11 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -32,11 +32,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
{ {
if (exception is ProxyHttpException phex) if (exception is ProxyHttpException phex)
{ {
await WriteToConsole(exception.Message + ": " + phex.InnerException?.Message, true); await writeToConsole(exception.Message + ": " + phex.InnerException?.Message, true);
} }
else else
{ {
await WriteToConsole(exception.Message, true); await writeToConsole(exception.Message, true);
} }
}; };
proxyServer.ForwardToUpstreamGateway = true; proxyServer.ForwardToUpstreamGateway = true;
...@@ -52,8 +52,8 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -52,8 +52,8 @@ namespace Titanium.Web.Proxy.Examples.Basic
public void StartProxy() public void StartProxy()
{ {
proxyServer.BeforeRequest += OnRequest; proxyServer.BeforeRequest += onRequest;
proxyServer.BeforeResponse += OnResponse; proxyServer.BeforeResponse += onResponse;
proxyServer.ServerCertificateValidationCallback += OnCertificateValidation; proxyServer.ServerCertificateValidationCallback += OnCertificateValidation;
proxyServer.ClientCertificateSelectionCallback += OnCertificateSelection; proxyServer.ClientCertificateSelectionCallback += OnCertificateSelection;
...@@ -63,7 +63,7 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -63,7 +63,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000); explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000);
// Fired when a CONNECT request is received // Fired when a CONNECT request is received
explicitEndPoint.BeforeTunnelConnectRequest += OnBeforeTunnelConnectRequest; explicitEndPoint.BeforeTunnelConnectRequest += onBeforeTunnelConnectRequest;
explicitEndPoint.BeforeTunnelConnectResponse += OnBeforeTunnelConnectResponse; explicitEndPoint.BeforeTunnelConnectResponse += OnBeforeTunnelConnectResponse;
// An explicit endpoint is where the client knows about the existence of a proxy // An explicit endpoint is where the client knows about the existence of a proxy
...@@ -102,11 +102,11 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -102,11 +102,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
public void Stop() public void Stop()
{ {
explicitEndPoint.BeforeTunnelConnectRequest -= OnBeforeTunnelConnectRequest; explicitEndPoint.BeforeTunnelConnectRequest -= onBeforeTunnelConnectRequest;
explicitEndPoint.BeforeTunnelConnectResponse -= OnBeforeTunnelConnectResponse; explicitEndPoint.BeforeTunnelConnectResponse -= OnBeforeTunnelConnectResponse;
proxyServer.BeforeRequest -= OnRequest; proxyServer.BeforeRequest -= onRequest;
proxyServer.BeforeResponse -= OnResponse; proxyServer.BeforeResponse -= onResponse;
proxyServer.ServerCertificateValidationCallback -= OnCertificateValidation; proxyServer.ServerCertificateValidationCallback -= OnCertificateValidation;
proxyServer.ClientCertificateSelectionCallback -= OnCertificateSelection; proxyServer.ClientCertificateSelectionCallback -= OnCertificateSelection;
...@@ -116,10 +116,10 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -116,10 +116,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
//proxyServer.CertificateManager.RemoveTrustedRootCertificates(); //proxyServer.CertificateManager.RemoveTrustedRootCertificates();
} }
private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e) private async Task onBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
{ {
string hostname = e.HttpClient.Request.RequestUri.Host; string hostname = e.HttpClient.Request.RequestUri.Host;
await WriteToConsole("Tunnel to: " + hostname); await writeToConsole("Tunnel to: " + hostname);
if (hostname.Contains("dropbox.com")) if (hostname.Contains("dropbox.com"))
{ {
...@@ -136,10 +136,10 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -136,10 +136,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
} }
// intecept & cancel redirect or update requests // intecept & cancel redirect or update requests
private async Task OnRequest(object sender, SessionEventArgs e) private async Task onRequest(object sender, SessionEventArgs e)
{ {
await WriteToConsole("Active Client Connections:" + ((ProxyServer)sender).ClientConnectionCount); await writeToConsole("Active Client Connections:" + ((ProxyServer)sender).ClientConnectionCount);
await WriteToConsole(e.HttpClient.Request.Url); await writeToConsole(e.HttpClient.Request.Url);
// store it in the UserData property // store it in the UserData property
// It can be a simple integer, Guid, or any type // It can be a simple integer, Guid, or any type
...@@ -177,19 +177,19 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -177,19 +177,19 @@ namespace Titanium.Web.Proxy.Examples.Basic
} }
// Modify response // Modify response
private async Task MultipartRequestPartSent(object sender, MultipartRequestPartSentEventArgs e) private async Task multipartRequestPartSent(object sender, MultipartRequestPartSentEventArgs e)
{ {
var session = (SessionEventArgs)sender; var session = (SessionEventArgs)sender;
await WriteToConsole("Multipart form data headers:"); await writeToConsole("Multipart form data headers:");
foreach (var header in e.Headers) foreach (var header in e.Headers)
{ {
await WriteToConsole(header.ToString()); await writeToConsole(header.ToString());
} }
} }
private async Task OnResponse(object sender, SessionEventArgs e) private async Task onResponse(object sender, SessionEventArgs e)
{ {
await WriteToConsole("Active Server Connections:" + ((ProxyServer)sender).ServerConnectionCount); await writeToConsole("Active Server Connections:" + ((ProxyServer)sender).ServerConnectionCount);
string ext = System.IO.Path.GetExtension(e.HttpClient.Request.RequestUri.AbsolutePath); string ext = System.IO.Path.GetExtension(e.HttpClient.Request.RequestUri.AbsolutePath);
...@@ -261,7 +261,7 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -261,7 +261,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
return Task.FromResult(0); return Task.FromResult(0);
} }
private async Task WriteToConsole(string message, bool useRedColor = false) private async Task writeToConsole(string message, bool useRedColor = false)
{ {
await @lock.WaitAsync(); await @lock.WaitAsync();
......
...@@ -106,7 +106,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -106,7 +106,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
if (value != selectedSession) if (value != selectedSession)
{ {
selectedSession = value; selectedSession = value;
SelectedSessionChanged(); selectedSessionChanged();
} }
} }
} }
...@@ -131,7 +131,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -131,7 +131,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
e.DecryptSsl = false; e.DecryptSsl = false;
} }
await Dispatcher.InvokeAsync(() => { AddSession(e); }); await Dispatcher.InvokeAsync(() => { addSession(e); });
} }
private async Task ProxyServer_BeforeTunnelConnectResponse(object sender, TunnelConnectSessionEventArgs e) private async Task ProxyServer_BeforeTunnelConnectResponse(object sender, TunnelConnectSessionEventArgs e)
...@@ -148,7 +148,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -148,7 +148,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
private async Task ProxyServer_BeforeRequest(object sender, SessionEventArgs e) private async Task ProxyServer_BeforeRequest(object sender, SessionEventArgs e)
{ {
SessionListItem item = null; SessionListItem item = null;
await Dispatcher.InvokeAsync(() => { item = AddSession(e); }); await Dispatcher.InvokeAsync(() => { item = addSession(e); });
if (e.HttpClient.Request.HasBody) if (e.HttpClient.Request.HasBody)
{ {
...@@ -191,15 +191,15 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -191,15 +191,15 @@ namespace Titanium.Web.Proxy.Examples.Wpf
}); });
} }
private SessionListItem AddSession(SessionEventArgsBase e) private SessionListItem addSession(SessionEventArgsBase e)
{ {
var item = CreateSessionListItem(e); var item = createSessionListItem(e);
Sessions.Add(item); Sessions.Add(item);
sessionDictionary.Add(e.HttpClient, item); sessionDictionary.Add(e.HttpClient, item);
return item; return item;
} }
private SessionListItem CreateSessionListItem(SessionEventArgsBase e) private SessionListItem createSessionListItem(SessionEventArgsBase e)
{ {
lastSessionNumber++; lastSessionNumber++;
bool isTunnelConnect = e is TunnelConnectSessionEventArgs; bool isTunnelConnect = e is TunnelConnectSessionEventArgs;
...@@ -248,7 +248,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -248,7 +248,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
} }
} }
private void SelectedSessionChanged() private void selectedSessionChanged()
{ {
if (SelectedSession == null) if (SelectedSession == null)
{ {
......
...@@ -19,10 +19,12 @@ ...@@ -19,10 +19,12 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MTA/@EntryIndexedValue">MTA</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MTA/@EntryIndexedValue">MTA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OID/@EntryIndexedValue">OID</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OID/@EntryIndexedValue">OID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OIDS/@EntryIndexedValue">OIDS</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OIDS/@EntryIndexedValue">OIDS</s:String>
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpNaming/ApplyAutoDetectedRules/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=a4ab2e69_002D4d9c_002D4345_002Dbcd1_002D5541dacf5d38/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="Method (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="METHOD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=a4ab2e69_002D4d9c_002D4345_002Dbcd1_002D5541dacf5d38/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="Method (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="METHOD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=dda2ffa1_002D435c_002D4111_002D88eb_002D1a7c93c382f0/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="Property (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="PROPERTY" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=dda2ffa1_002D435c_002D4111_002D88eb_002D1a7c93c382f0/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="Property (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="PROPERTY" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
......
...@@ -117,7 +117,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -117,7 +117,7 @@ namespace Titanium.Web.Proxy.EventArguments
} }
catch (Exception ex) catch (Exception ex)
{ {
exceptionFunc(new Exception("Exception thrown in user event", ex)); ExceptionFunc(new Exception("Exception thrown in user event", ex));
} }
} }
...@@ -154,7 +154,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -154,7 +154,7 @@ namespace Titanium.Web.Proxy.EventArguments
{ {
using (var bodyStream = new MemoryStream()) using (var bodyStream = new MemoryStream())
{ {
var writer = new HttpWriter(bodyStream, bufferPool, bufferSize); var writer = new HttpWriter(bodyStream, BufferPool, BufferSize);
if (isRequest) if (isRequest)
{ {
...@@ -186,7 +186,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -186,7 +186,7 @@ namespace Titanium.Web.Proxy.EventArguments
using (var bodyStream = new MemoryStream()) using (var bodyStream = new MemoryStream())
{ {
var writer = new HttpWriter(bodyStream, bufferPool, bufferSize); var writer = new HttpWriter(bodyStream, BufferPool, BufferSize);
await copyBodyAsync(isRequest, true, writer, TransformationMode.None, null, cancellationToken); await copyBodyAsync(isRequest, true, writer, TransformationMode.None, null, cancellationToken);
} }
} }
...@@ -207,7 +207,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -207,7 +207,7 @@ namespace Titanium.Web.Proxy.EventArguments
var reader = getStreamReader(true); var reader = getStreamReader(true);
string boundary = HttpHelper.GetBoundaryFromContentType(request.ContentType); string boundary = HttpHelper.GetBoundaryFromContentType(request.ContentType);
using (var copyStream = new CopyStream(reader, writer, bufferPool, bufferSize)) using (var copyStream = new CopyStream(reader, writer, BufferPool, BufferSize))
{ {
while (contentLength > copyStream.ReadBytes) while (contentLength > copyStream.ReadBytes)
{ {
...@@ -259,7 +259,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -259,7 +259,7 @@ namespace Titanium.Web.Proxy.EventArguments
string contentEncoding = useOriginalHeaderValues ? requestResponse.OriginalContentEncoding : requestResponse.ContentEncoding; string contentEncoding = useOriginalHeaderValues ? requestResponse.OriginalContentEncoding : requestResponse.ContentEncoding;
Stream s = limitedStream = new LimitedStream(stream, bufferPool, isChunked, contentLength); Stream s = limitedStream = new LimitedStream(stream, BufferPool, isChunked, contentLength);
if (transformation == TransformationMode.Uncompress && contentEncoding != null) if (transformation == TransformationMode.Uncompress && contentEncoding != null)
{ {
...@@ -268,7 +268,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -268,7 +268,7 @@ namespace Titanium.Web.Proxy.EventArguments
try try
{ {
using (var bufStream = new CustomBufferedStream(s, bufferPool, bufferSize, true)) using (var bufStream = new CustomBufferedStream(s, BufferPool, BufferSize, true))
{ {
await writer.CopyBodyAsync(bufStream, false, -1, onCopy, cancellationToken); await writer.CopyBodyAsync(bufStream, false, -1, onCopy, cancellationToken);
} }
...@@ -290,7 +290,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -290,7 +290,7 @@ namespace Titanium.Web.Proxy.EventArguments
{ {
int bufferDataLength = 0; int bufferDataLength = 0;
var buffer = bufferPool.GetBuffer(bufferSize); var buffer = BufferPool.GetBuffer(BufferSize);
try try
{ {
int boundaryLength = boundary.Length + 4; int boundaryLength = boundary.Length + 4;
...@@ -340,7 +340,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -340,7 +340,7 @@ namespace Titanium.Web.Proxy.EventArguments
} }
finally finally
{ {
bufferPool.ReturnBuffer(buffer); BufferPool.ReturnBuffer(buffer);
} }
} }
......
...@@ -24,9 +24,9 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -24,9 +24,9 @@ namespace Titanium.Web.Proxy.EventArguments
internal TcpServerConnection ServerConnection => HttpClient.Connection; internal TcpServerConnection ServerConnection => HttpClient.Connection;
internal TcpClientConnection ClientConnection => ProxyClient.Connection; internal TcpClientConnection ClientConnection => ProxyClient.Connection;
protected readonly int bufferSize; protected readonly int BufferSize;
protected readonly IBufferPool bufferPool; protected readonly IBufferPool BufferPool;
protected readonly ExceptionHandler exceptionFunc; protected readonly ExceptionHandler ExceptionFunc;
/// <summary> /// <summary>
/// Relative milliseconds for various events. /// Relative milliseconds for various events.
...@@ -39,9 +39,9 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -39,9 +39,9 @@ namespace Titanium.Web.Proxy.EventArguments
private SessionEventArgsBase(ProxyServer server, ProxyEndPoint endPoint, private SessionEventArgsBase(ProxyServer server, ProxyEndPoint endPoint,
CancellationTokenSource cancellationTokenSource) CancellationTokenSource cancellationTokenSource)
{ {
bufferSize = server.BufferSize; BufferSize = server.BufferSize;
bufferPool = server.BufferPool; BufferPool = server.BufferPool;
exceptionFunc = server.ExceptionFunc; ExceptionFunc = server.ExceptionFunc;
TimeLine["Session Created"] = DateTime.Now; TimeLine["Session Created"] = DateTime.Now;
} }
...@@ -161,7 +161,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -161,7 +161,7 @@ namespace Titanium.Web.Proxy.EventArguments
} }
catch (Exception ex) catch (Exception ex)
{ {
exceptionFunc(new Exception("Exception thrown in user event", ex)); ExceptionFunc(new Exception("Exception thrown in user event", ex));
} }
} }
...@@ -173,7 +173,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -173,7 +173,7 @@ namespace Titanium.Web.Proxy.EventArguments
} }
catch (Exception ex) catch (Exception ex)
{ {
exceptionFunc(new Exception("Exception thrown in user event", ex)); ExceptionFunc(new Exception("Exception thrown in user event", ex));
} }
} }
......
...@@ -70,7 +70,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -70,7 +70,7 @@ namespace Titanium.Web.Proxy.Helpers
internal static bool IsRunningAsUwp() internal static bool IsRunningAsUwp()
{ {
if (IsWindows7OrLower) if (isWindows7OrLower)
{ {
return false; return false;
} }
...@@ -87,7 +87,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -87,7 +87,7 @@ namespace Titanium.Web.Proxy.Helpers
} }
} }
private static bool IsWindows7OrLower private static bool isWindows7OrLower
{ {
get get
{ {
......
...@@ -80,7 +80,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -80,7 +80,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <param name="protocolType"></param> /// <param name="protocolType"></param>
internal void SetProxy(string hostname, int port, ProxyProtocolType protocolType) internal void SetProxy(string hostname, int port, ProxyProtocolType protocolType)
{ {
using (var reg = OpenInternetSettingsKey()) using (var reg = openInternetSettingsKey())
{ {
if (reg == null) if (reg == null)
{ {
...@@ -127,7 +127,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -127,7 +127,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary> /// </summary>
internal void RemoveProxy(ProxyProtocolType protocolType, bool saveOriginalConfig = true) internal void RemoveProxy(ProxyProtocolType protocolType, bool saveOriginalConfig = true)
{ {
using (var reg = OpenInternetSettingsKey()) using (var reg = openInternetSettingsKey())
{ {
if (reg == null) if (reg == null)
{ {
...@@ -168,7 +168,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -168,7 +168,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary> /// </summary>
internal void DisableAllProxy() internal void DisableAllProxy()
{ {
using (var reg = OpenInternetSettingsKey()) using (var reg = openInternetSettingsKey())
{ {
if (reg == null) if (reg == null)
{ {
...@@ -186,7 +186,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -186,7 +186,7 @@ namespace Titanium.Web.Proxy.Helpers
internal void SetAutoProxyUrl(string url) internal void SetAutoProxyUrl(string url)
{ {
using (var reg = OpenInternetSettingsKey()) using (var reg = openInternetSettingsKey())
{ {
if (reg == null) if (reg == null)
{ {
...@@ -201,7 +201,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -201,7 +201,7 @@ namespace Titanium.Web.Proxy.Helpers
internal void SetProxyOverride(string proxyOverride) internal void SetProxyOverride(string proxyOverride)
{ {
using (var reg = OpenInternetSettingsKey()) using (var reg = openInternetSettingsKey())
{ {
if (reg == null) if (reg == null)
{ {
...@@ -286,7 +286,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -286,7 +286,7 @@ namespace Titanium.Web.Proxy.Helpers
internal ProxyInfo GetProxyInfoFromRegistry() internal ProxyInfo GetProxyInfoFromRegistry()
{ {
using (var reg = OpenInternetSettingsKey()) using (var reg = openInternetSettingsKey())
{ {
if (reg == null) if (reg == null)
{ {
...@@ -347,7 +347,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -347,7 +347,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <summary> /// <summary>
/// Opens the registry key with the internet settings /// Opens the registry key with the internet settings
/// </summary> /// </summary>
private static RegistryKey OpenInternetSettingsKey() private static RegistryKey openInternetSettingsKey()
{ {
return Registry.CurrentUser.OpenSubKey(regKeyInternetSettings, true); return Registry.CurrentUser.OpenSubKey(regKeyInternetSettings, true);
} }
......
...@@ -38,11 +38,11 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -38,11 +38,11 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal TcpConnectionFactory(ProxyServer server) internal TcpConnectionFactory(ProxyServer server)
{ {
this.server = server; this.Server = server;
Task.Run(async () => await clearOutdatedConnections()); Task.Run(async () => await clearOutdatedConnections());
} }
internal ProxyServer server { get; set; } internal ProxyServer Server { get; set; }
internal string GetConnectionCacheKey(string remoteHostName, int remotePort, internal string GetConnectionCacheKey(string remoteHostName, int remotePort,
bool isHttps, List<SslApplicationProtocol> applicationProtocols, bool isHttps, List<SslApplicationProtocol> applicationProtocols,
...@@ -232,7 +232,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -232,7 +232,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
//deny connection to proxy end points to avoid infinite connection loop. //deny connection to proxy end points to avoid infinite connection loop.
if (server.ProxyEndPoints.Any(x => x.Port == remotePort) if (Server.ProxyEndPoints.Any(x => x.Port == remotePort)
&& NetworkHelper.IsLocalIpAddress(remoteHostName)) && NetworkHelper.IsLocalIpAddress(remoteHostName))
{ {
throw new Exception($"A client is making HTTP request to one of the listening ports of this proxy {remoteHostName}:{remotePort}"); throw new Exception($"A client is making HTTP request to one of the listening ports of this proxy {remoteHostName}:{remotePort}");
...@@ -240,7 +240,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -240,7 +240,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
if (externalProxy != null) if (externalProxy != null)
{ {
if (server.ProxyEndPoints.Any(x => x.Port == externalProxy.Port) if (Server.ProxyEndPoints.Any(x => x.Port == externalProxy.Port)
&& NetworkHelper.IsLocalIpAddress(externalProxy.HostName)) && NetworkHelper.IsLocalIpAddress(externalProxy.HostName))
{ {
throw new Exception($"A client is making HTTP request via external proxy to one of the listening ports of this proxy {remoteHostName}:{remotePort}"); throw new Exception($"A client is making HTTP request via external proxy to one of the listening ports of this proxy {remoteHostName}:{remotePort}");
...@@ -416,7 +416,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -416,7 +416,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
return; return;
} }
if (close || connection.IsWinAuthenticated || !server.EnableConnectionPool || connection.Stream.IsClosed) if (close || connection.IsWinAuthenticated || !Server.EnableConnectionPool || connection.Stream.IsClosed)
{ {
disposalBag.Add(connection); disposalBag.Add(connection);
return; return;
...@@ -432,7 +432,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -432,7 +432,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
{ {
if (cache.TryGetValue(connection.CacheKey, out var existingConnections)) if (cache.TryGetValue(connection.CacheKey, out var existingConnections))
{ {
while (existingConnections.Count >= server.MaxCachedConnections) while (existingConnections.Count >= Server.MaxCachedConnections)
{ {
if (existingConnections.TryDequeue(out var staleConnection)) if (existingConnections.TryDequeue(out var staleConnection))
{ {
...@@ -489,8 +489,8 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -489,8 +489,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
{ {
if (queue.TryDequeue(out var connection)) if (queue.TryDequeue(out var connection))
{ {
var cutOff = DateTime.Now.AddSeconds(-1 * server.ConnectionTimeOutSeconds); var cutOff = DateTime.Now.AddSeconds(-1 * Server.ConnectionTimeOutSeconds);
if (!server.EnableConnectionPool if (!Server.EnableConnectionPool
|| connection.LastAccess < cutOff) || connection.LastAccess < cutOff)
{ {
disposalBag.Add(connection); disposalBag.Add(connection);
...@@ -530,7 +530,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -530,7 +530,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
} }
catch (Exception e) catch (Exception e)
{ {
server.ExceptionFunc(new Exception("An error occurred when disposing server connections.", e)); Server.ExceptionFunc(new Exception("An error occurred when disposing server connections.", e));
} }
finally finally
{ {
......
// //
// Mono.Security.BitConverterLE.cs // Mono.Security.BitConverterLE.cs
// Like System.BitConverter but always little endian // Like System.BitConverter but always little endian
// //
......
...@@ -43,7 +43,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers ...@@ -43,7 +43,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
if (!requireBody) if (!requireBody)
return request as Request; return request as Request;
if (ParseBody(reader, ref request)) if (parseBody(reader, ref request))
return request as Request; return request as Request;
} }
catch { } catch { }
...@@ -84,7 +84,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers ...@@ -84,7 +84,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
if (line?.Length != 0) if (line?.Length != 0)
return null; return null;
if (ParseBody(reader, ref response)) if (parseBody(reader, ref response))
return response as Response; return response as Response;
} }
catch { } catch { }
...@@ -92,7 +92,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers ...@@ -92,7 +92,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
return null; return null;
} }
private static bool ParseBody(StringReader reader, ref RequestResponseBase obj) private static bool parseBody(StringReader reader, ref RequestResponseBase obj)
{ {
obj.OriginalContentLength = obj.ContentLength; obj.OriginalContentLength = obj.ContentLength;
if (obj.ContentLength <= 0) if (obj.ContentLength <= 0)
......
...@@ -11,22 +11,22 @@ namespace Titanium.Web.Proxy.UnitTests ...@@ -11,22 +11,22 @@ namespace Titanium.Web.Proxy.UnitTests
public class SystemProxyTest public class SystemProxyTest
{ {
[TestMethod] [TestMethod]
public void CompareProxyAdddressReturendByWebProxyAndWinHttpProxyResolver() public void CompareProxyAddressReturnedByWebProxyAndWinHttpProxyResolver()
{ {
var proxyManager = new SystemProxyManager(); var proxyManager = new SystemProxyManager();
try try
{ {
CompareUrls(); compareUrls();
proxyManager.SetProxy("127.0.0.1", 8000, ProxyProtocolType.Http); proxyManager.SetProxy("127.0.0.1", 8000, ProxyProtocolType.Http);
CompareUrls(); compareUrls();
proxyManager.SetProxy("127.0.0.1", 8000, ProxyProtocolType.Https); proxyManager.SetProxy("127.0.0.1", 8000, ProxyProtocolType.Https);
CompareUrls(); compareUrls();
proxyManager.SetProxy("127.0.0.1", 8000, ProxyProtocolType.AllHttp); proxyManager.SetProxy("127.0.0.1", 8000, ProxyProtocolType.AllHttp);
CompareUrls(); compareUrls();
// for this test you need to add a proxy.pac file to a local webserver // for this test you need to add a proxy.pac file to a local webserver
//function FindProxyForURL(url, host) //function FindProxyForURL(url, host)
...@@ -43,25 +43,25 @@ namespace Titanium.Web.Proxy.UnitTests ...@@ -43,25 +43,25 @@ namespace Titanium.Web.Proxy.UnitTests
//CompareUrls(); //CompareUrls();
proxyManager.SetProxyOverride("<-loopback>"); proxyManager.SetProxyOverride("<-loopback>");
CompareUrls(); compareUrls();
proxyManager.SetProxyOverride("<local>"); proxyManager.SetProxyOverride("<local>");
CompareUrls(); compareUrls();
proxyManager.SetProxyOverride("yahoo.com"); proxyManager.SetProxyOverride("yahoo.com");
CompareUrls(); compareUrls();
proxyManager.SetProxyOverride("*.local"); proxyManager.SetProxyOverride("*.local");
CompareUrls(); compareUrls();
proxyManager.SetProxyOverride("http://*.local"); proxyManager.SetProxyOverride("http://*.local");
CompareUrls(); compareUrls();
proxyManager.SetProxyOverride("<-loopback>;*.local"); proxyManager.SetProxyOverride("<-loopback>;*.local");
CompareUrls(); compareUrls();
proxyManager.SetProxyOverride("<-loopback>;*.local;<local>"); proxyManager.SetProxyOverride("<-loopback>;*.local;<local>");
CompareUrls(); compareUrls();
} }
finally finally
{ {
...@@ -69,7 +69,7 @@ namespace Titanium.Web.Proxy.UnitTests ...@@ -69,7 +69,7 @@ namespace Titanium.Web.Proxy.UnitTests
} }
} }
private void CompareUrls() private void compareUrls()
{ {
var webProxy = WebRequest.GetSystemWebProxy(); var webProxy = WebRequest.GetSystemWebProxy();
......
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