Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit e704661

Browse files
Merge pull request #333 from justcoding121/develop
netstandard2 proxy start fix
2 parents 4640ea3 + bde005d commit e704661

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

Titanium.Web.Proxy/ProxyServer.cs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ public partial class ProxyServer : IDisposable
3434
internal const string UriSchemeHttps = "https";
3535
#endif
3636

37-
/// <summary>
38-
/// Is the proxy currently running
39-
/// </summary>
40-
private bool proxyRunning { get; set; }
41-
4237
/// <summary>
4338
/// An default exception log func
4439
/// </summary>
@@ -225,7 +220,7 @@ public CertificateEngine CertificateEngine
225220
/// <summary>
226221
/// Is the proxy currently running
227222
/// </summary>
228-
public bool ProxyRunning => proxyRunning;
223+
public bool ProxyRunning { get; private set; }
229224

230225
/// <summary>
231226
/// Gets or sets a value indicating whether requests will be chained to upstream gateway.
@@ -354,7 +349,7 @@ public void AddEndPoint(ProxyEndPoint endPoint)
354349

355350
ProxyEndPoints.Add(endPoint);
356351

357-
if (proxyRunning)
352+
if (ProxyRunning)
358353
{
359354
Listen(endPoint);
360355
}
@@ -374,7 +369,7 @@ public void RemoveEndPoint(ProxyEndPoint endPoint)
374369

375370
ProxyEndPoints.Remove(endPoint);
376371

377-
if (proxyRunning)
372+
if (ProxyRunning)
378373
{
379374
QuitListen(endPoint);
380375
}
@@ -533,7 +528,7 @@ public void DisableAllSystemProxies()
533528
/// </summary>
534529
public void Start()
535530
{
536-
if (proxyRunning)
531+
if (ProxyRunning)
537532
{
538533
throw new Exception("Proxy is already running.");
539534
}
@@ -575,6 +570,8 @@ public void Start()
575570
}
576571
#endif
577572

573+
ProxyRunning = true;
574+
578575
foreach (var endPoint in ProxyEndPoints)
579576
{
580577
Listen(endPoint);
@@ -587,8 +584,6 @@ public void Start()
587584
//clear orphaned windows auth states every 2 minutes
588585
WinAuthEndPoint.ClearIdleStates(2);
589586
}
590-
591-
proxyRunning = true;
592587
}
593588

594589

@@ -597,7 +592,7 @@ public void Start()
597592
/// </summary>
598593
public void Stop()
599594
{
600-
if (!proxyRunning)
595+
if (!ProxyRunning)
601596
{
602597
throw new Exception("Proxy is not running.");
603598
}
@@ -623,7 +618,7 @@ public void Stop()
623618

624619
CertificateManager?.StopClearIdleCertificates();
625620

626-
proxyRunning = false;
621+
ProxyRunning = false;
627622
}
628623

629624
/// <summary>
@@ -653,7 +648,7 @@ private void Dispose(CustomBufferedStream clientStream, CustomBinaryReader clien
653648
/// </summary>
654649
public void Dispose()
655650
{
656-
if (proxyRunning)
651+
if (ProxyRunning)
657652
{
658653
Stop();
659654
}
@@ -683,7 +678,7 @@ private async void Listen(ProxyEndPoint endPoint)
683678

684679
endPoint.Port = ((IPEndPoint)endPoint.Listener.LocalEndpoint).Port;
685680

686-
while (proxyRunning)
681+
while (ProxyRunning)
687682
{
688683
try
689684
{
@@ -712,7 +707,7 @@ private void ValidateEndPointAsSystemProxy(ExplicitProxyEndPoint endPoint)
712707
throw new Exception("Cannot set endPoints not added to proxy as system proxy");
713708
}
714709

715-
if (!proxyRunning)
710+
if (!ProxyRunning)
716711
{
717712
throw new Exception("Cannot set system proxy settings before proxy has been started.");
718713
}

0 commit comments

Comments
 (0)