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
proxyServer.ExceptionFunc = exception => Console.WriteLine(exception.Message);
proxyServer.TrustRootCertificate = true;
//proxyServer.ForwardToUpstreamGateway = true;
proxyServer.ForwardToUpstreamGateway = true;
//optionally set the Certificate Engine
//Under Mono only BouncyCastle will be supported
......
......@@ -163,12 +163,15 @@ namespace Titanium.Web.Proxy.Helpers
/// <summary>
/// Remove the HTTP and/or HTTPS proxy setting from current machine
/// </summary>
internal void RemoveProxy(ProxyProtocolType protocolType)
internal void RemoveProxy(ProxyProtocolType protocolType, bool saveOriginalConfig = true)
{
var reg = Registry.CurrentUser.OpenSubKey(regKeyInternetSettings, true);
if (reg != null)
{
SaveOriginalProxyConfiguration(reg);
if (saveOriginalConfig)
{
SaveOriginalProxyConfiguration(reg);
}
if (reg.GetValue(regProxyServer) != null)
{
......
......@@ -500,6 +500,23 @@ namespace Titanium.Web.Proxy
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
&& GetCustomUpStreamHttpProxyFunc == null && GetCustomUpStreamHttpsProxyFunc == 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