Commit bde005da authored by Honfika's avatar Honfika

netstandard2 proxy start fix

parent bfb66f70
...@@ -34,11 +34,6 @@ namespace Titanium.Web.Proxy ...@@ -34,11 +34,6 @@ namespace Titanium.Web.Proxy
internal const string UriSchemeHttps = "https"; internal const string UriSchemeHttps = "https";
#endif #endif
/// <summary>
/// Is the proxy currently running
/// </summary>
private bool proxyRunning { get; set; }
/// <summary> /// <summary>
/// An default exception log func /// An default exception log func
/// </summary> /// </summary>
...@@ -225,7 +220,7 @@ namespace Titanium.Web.Proxy ...@@ -225,7 +220,7 @@ namespace Titanium.Web.Proxy
/// <summary> /// <summary>
/// Is the proxy currently running /// Is the proxy currently running
/// </summary> /// </summary>
public bool ProxyRunning => proxyRunning; public bool ProxyRunning { get; private set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether requests will be chained to upstream gateway. /// Gets or sets a value indicating whether requests will be chained to upstream gateway.
...@@ -354,7 +349,7 @@ namespace Titanium.Web.Proxy ...@@ -354,7 +349,7 @@ namespace Titanium.Web.Proxy
ProxyEndPoints.Add(endPoint); ProxyEndPoints.Add(endPoint);
if (proxyRunning) if (ProxyRunning)
{ {
Listen(endPoint); Listen(endPoint);
} }
...@@ -374,7 +369,7 @@ namespace Titanium.Web.Proxy ...@@ -374,7 +369,7 @@ namespace Titanium.Web.Proxy
ProxyEndPoints.Remove(endPoint); ProxyEndPoints.Remove(endPoint);
if (proxyRunning) if (ProxyRunning)
{ {
QuitListen(endPoint); QuitListen(endPoint);
} }
...@@ -533,7 +528,7 @@ namespace Titanium.Web.Proxy ...@@ -533,7 +528,7 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public void Start() public void Start()
{ {
if (proxyRunning) if (ProxyRunning)
{ {
throw new Exception("Proxy is already running."); throw new Exception("Proxy is already running.");
} }
...@@ -575,6 +570,8 @@ namespace Titanium.Web.Proxy ...@@ -575,6 +570,8 @@ namespace Titanium.Web.Proxy
} }
#endif #endif
ProxyRunning = true;
foreach (var endPoint in ProxyEndPoints) foreach (var endPoint in ProxyEndPoints)
{ {
Listen(endPoint); Listen(endPoint);
...@@ -587,8 +584,6 @@ namespace Titanium.Web.Proxy ...@@ -587,8 +584,6 @@ namespace Titanium.Web.Proxy
//clear orphaned windows auth states every 2 minutes //clear orphaned windows auth states every 2 minutes
WinAuthEndPoint.ClearIdleStates(2); WinAuthEndPoint.ClearIdleStates(2);
} }
proxyRunning = true;
} }
...@@ -597,7 +592,7 @@ namespace Titanium.Web.Proxy ...@@ -597,7 +592,7 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public void Stop() public void Stop()
{ {
if (!proxyRunning) if (!ProxyRunning)
{ {
throw new Exception("Proxy is not running."); throw new Exception("Proxy is not running.");
} }
...@@ -623,7 +618,7 @@ namespace Titanium.Web.Proxy ...@@ -623,7 +618,7 @@ namespace Titanium.Web.Proxy
CertificateManager?.StopClearIdleCertificates(); CertificateManager?.StopClearIdleCertificates();
proxyRunning = false; ProxyRunning = false;
} }
/// <summary> /// <summary>
...@@ -653,7 +648,7 @@ namespace Titanium.Web.Proxy ...@@ -653,7 +648,7 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public void Dispose() public void Dispose()
{ {
if (proxyRunning) if (ProxyRunning)
{ {
Stop(); Stop();
} }
...@@ -683,7 +678,7 @@ namespace Titanium.Web.Proxy ...@@ -683,7 +678,7 @@ namespace Titanium.Web.Proxy
endPoint.Port = ((IPEndPoint)endPoint.Listener.LocalEndpoint).Port; endPoint.Port = ((IPEndPoint)endPoint.Listener.LocalEndpoint).Port;
while (proxyRunning) while (ProxyRunning)
{ {
try try
{ {
...@@ -712,7 +707,7 @@ namespace Titanium.Web.Proxy ...@@ -712,7 +707,7 @@ namespace Titanium.Web.Proxy
throw new Exception("Cannot set endPoints not added to proxy as system proxy"); throw new Exception("Cannot set endPoints not added to proxy as system proxy");
} }
if (!proxyRunning) if (!ProxyRunning)
{ {
throw new Exception("Cannot set system proxy settings before proxy has been started."); throw new Exception("Cannot set system proxy settings before proxy has been started.");
} }
......
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