From 3b5c09907d95e031adc09d07460a7352a3f2b6d1 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Sun, 23 Nov 2014 01:08:09 +0800 Subject: [PATCH] only switch the system proxy off if we have switched it on --- shadowsocks-csharp/Controller/ShadowsocksController.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shadowsocks-csharp/Controller/ShadowsocksController.cs b/shadowsocks-csharp/Controller/ShadowsocksController.cs index b4de4cf9..f5bdb44c 100755 --- a/shadowsocks-csharp/Controller/ShadowsocksController.cs +++ b/shadowsocks-csharp/Controller/ShadowsocksController.cs @@ -22,6 +22,8 @@ namespace Shadowsocks.Controller private PolipoRunner polipoRunner; private bool stopped = false; + private bool _systemProxyIsDirty = false; + public class PathEventArgs : EventArgs { public string Path; @@ -174,10 +176,16 @@ namespace Shadowsocks.Controller if (_config.enabled) { SystemProxy.Enable(); + _systemProxyIsDirty = true; } else { - SystemProxy.Disable(); + // only switch it off if we have switched it on + if (_systemProxyIsDirty) + { + SystemProxy.Disable(); + _systemProxyIsDirty = false; + } } }