Commit 36a721b4 authored by justcoding121's avatar justcoding121

#81

Fix quit
parent a426879b
...@@ -137,22 +137,15 @@ namespace Titanium.Web.Proxy ...@@ -137,22 +137,15 @@ namespace Titanium.Web.Proxy
RootCertificateName); RootCertificateName);
} }
/// <summary>
/// Initialize the proxy
/// </summary>
public void Initialize()
{
tcpConnectionCacheManager.ClearIdleConnections(ConnectionCacheTimeOutMinutes);
certificateCacheManager.ClearIdleCertificates(CertificateCacheTimeOutMinutes);
}
/// <summary> /// <summary>
/// Add a proxy end point /// Add a proxy end point
/// </summary> /// </summary>
/// <param name="endPoint"></param> /// <param name="endPoint"></param>
public void AddEndPoint(ProxyEndPoint endPoint) public void AddEndPoint(ProxyEndPoint endPoint)
{ {
if (ProxyEndPoints.Any(x=>x.IpAddress == endPoint.IpAddress && x.Port == endPoint.Port))
throw new Exception("Cannot add another endpoint to same port & ip address");
ProxyEndPoints.Add(endPoint); ProxyEndPoints.Add(endPoint);
if (proxyRunning) if (proxyRunning)
...@@ -166,7 +159,6 @@ namespace Titanium.Web.Proxy ...@@ -166,7 +159,6 @@ namespace Titanium.Web.Proxy
/// <param name="endPoint"></param> /// <param name="endPoint"></param>
public void RemoveEndPoint(ProxyEndPoint endPoint) public void RemoveEndPoint(ProxyEndPoint endPoint)
{ {
if (ProxyEndPoints.Contains(endPoint) == false) if (ProxyEndPoints.Contains(endPoint) == false)
throw new Exception("Cannot remove endPoints not added to proxy"); throw new Exception("Cannot remove endPoints not added to proxy");
...@@ -198,13 +190,6 @@ namespace Titanium.Web.Proxy ...@@ -198,13 +190,6 @@ namespace Titanium.Web.Proxy
} }
/// <summary>
/// Remove any HTTP proxy setting of current machien
/// </summary>
public void DisableSystemHttpProxy()
{
systemProxySettingsManager.RemoveHttpProxy();
}
/// <summary> /// <summary>
/// Set the given explicit end point as the default proxy server for current machine /// Set the given explicit end point as the default proxy server for current machine
...@@ -239,6 +224,14 @@ namespace Titanium.Web.Proxy ...@@ -239,6 +224,14 @@ namespace Titanium.Web.Proxy
Console.WriteLine("Set endpoint at Ip {1} and port: {2} as System HTTPS Proxy", endPoint.GetType().Name, endPoint.IpAddress, endPoint.Port); Console.WriteLine("Set endpoint at Ip {1} and port: {2} as System HTTPS Proxy", endPoint.GetType().Name, endPoint.IpAddress, endPoint.Port);
} }
/// <summary>
/// Remove any HTTP proxy setting of current machien
/// </summary>
public void DisableSystemHttpProxy()
{
systemProxySettingsManager.RemoveHttpProxy();
}
/// <summary> /// <summary>
/// Remove any HTTPS proxy setting for current machine /// Remove any HTTPS proxy setting for current machine
/// </summary> /// </summary>
...@@ -270,7 +263,8 @@ namespace Titanium.Web.Proxy ...@@ -270,7 +263,8 @@ namespace Titanium.Web.Proxy
Listen(endPoint); Listen(endPoint);
} }
Initialize(); tcpConnectionCacheManager.ClearIdleConnections(ConnectionCacheTimeOutMinutes);
certificateCacheManager.ClearIdleCertificates(CertificateCacheTimeOutMinutes);
proxyRunning = true; proxyRunning = true;
} }
...@@ -295,9 +289,11 @@ namespace Titanium.Web.Proxy ...@@ -295,9 +289,11 @@ namespace Titanium.Web.Proxy
foreach (var endPoint in ProxyEndPoints) foreach (var endPoint in ProxyEndPoints)
{ {
endPoint.listener.Stop(); QuitListen(endPoint);
} }
ProxyEndPoints.Clear();
tcpConnectionCacheManager.StopClearIdleConnections(); tcpConnectionCacheManager.StopClearIdleConnections();
certificateCacheManager.StopClearIdleCertificates(); certificateCacheManager.StopClearIdleCertificates();
...@@ -325,6 +321,8 @@ namespace Titanium.Web.Proxy ...@@ -325,6 +321,8 @@ namespace Titanium.Web.Proxy
private void QuitListen(ProxyEndPoint endPoint) private void QuitListen(ProxyEndPoint endPoint)
{ {
endPoint.listener.Stop(); endPoint.listener.Stop();
endPoint.listener.Server.Close();
endPoint.listener.Server.Dispose();
} }
/// <summary> /// <summary>
......
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