Commit d98c601d authored by justcoding121's avatar justcoding121 Committed by justcoding121

Merge pull request #272 from honfika/develop

remove proxy settings when it is probably remained there because a pr…
parents 72d493a9 aef8b18c
...@@ -31,7 +31,7 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -31,7 +31,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
proxyServer.ExceptionFunc = exception => Console.WriteLine(exception.Message); proxyServer.ExceptionFunc = exception => Console.WriteLine(exception.Message);
proxyServer.TrustRootCertificate = true; proxyServer.TrustRootCertificate = true;
//proxyServer.ForwardToUpstreamGateway = true; proxyServer.ForwardToUpstreamGateway = true;
//optionally set the Certificate Engine //optionally set the Certificate Engine
//Under Mono only BouncyCastle will be supported //Under Mono only BouncyCastle will be supported
......
...@@ -163,12 +163,15 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -163,12 +163,15 @@ namespace Titanium.Web.Proxy.Helpers
/// <summary> /// <summary>
/// Remove the HTTP and/or HTTPS proxy setting from current machine /// Remove the HTTP and/or HTTPS proxy setting from current machine
/// </summary> /// </summary>
internal void RemoveProxy(ProxyProtocolType protocolType) internal void RemoveProxy(ProxyProtocolType protocolType, bool saveOriginalConfig = true)
{ {
var reg = Registry.CurrentUser.OpenSubKey(regKeyInternetSettings, true); var reg = Registry.CurrentUser.OpenSubKey(regKeyInternetSettings, true);
if (reg != null) if (reg != null)
{ {
SaveOriginalProxyConfiguration(reg); if (saveOriginalConfig)
{
SaveOriginalProxyConfiguration(reg);
}
if (reg.GetValue(regProxyServer) != null) if (reg.GetValue(regProxyServer) != null)
{ {
......
...@@ -500,6 +500,23 @@ namespace Titanium.Web.Proxy ...@@ -500,6 +500,23 @@ namespace Titanium.Web.Proxy
throw new Exception("Proxy is already running."); throw new Exception("Proxy is already running.");
} }
if (systemProxySettingsManager != null)
{
var proxyInfo = systemProxySettingsManager.GetProxyInfoFromRegistry();
if (proxyInfo.Proxies != null)
{
var proxies = proxyInfo.Proxies.ToArray();
foreach (var proxy in proxies)
{
var value = proxy.Value;
if (value.HostName == "127.0.0.1" && ProxyEndPoints.Any(x => x.Port == value.Port))
{
systemProxySettingsManager.RemoveProxy(value.ProtocolType, false);
}
}
}
}
if (ForwardToUpstreamGateway if (ForwardToUpstreamGateway
&& GetCustomUpStreamHttpProxyFunc == null && GetCustomUpStreamHttpsProxyFunc == null && GetCustomUpStreamHttpProxyFunc == null && GetCustomUpStreamHttpsProxyFunc == null
&& systemProxySettingsManager != null) && systemProxySettingsManager != null)
......
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