Please read Wiki carefully, especially https://github.com/shadowsocks/shadowsocks-windows/wiki/Troubleshooting.
Please answer these questions before submitting your issue. Thanks!
from v4.0
Windows 10 .Net4.6
many times for Toggle Enable System Proxy
Save should record original user settings.
IE Proxy be changed as last SS Win using.
None.
After system proxy is turned off, we should re-record user settings.
If you have any idea on improving it, open PR
But.. with current code logic, the SS will not save user settings, it will always save SSWin settings after user toggle "Enable System Proxy" many times.
Maybe first time the code works fine, but after many time trigger "Enable System Proxy", it will lost user settings.
My build with attached code changes works correct with your mind!
We should always use the first time saved user data to restore current settings when exiting or disabling SS.
Thanks!
你的代码逻辑有问题
这种流程下,预计应该还原到『用户设置二』,但是你的逻辑会还原到『用户设置一』
remove my code. sorry, I was wrong!
the root cause is a Windows shut down and user logoff when SS is working.
if user current wininet setting is PROXY_TYPE_AUTO_DETECT .
|
SS start - enable && global, so wininet is PROXY_TYPE_PROXY , and save user's ROXY_TYPE_AUTO_DETECT
|
Windows shutdown or user logoff. (Wininet keeping PROXY_TYPE_PROXY , and lost saving user's)
|
Back to Windows and Start up SS again.
|
SS start -enable && global, the wininet is is PROXY_TYPE_PROXY, and save previous Wininet keeping PROXY_TYPE_PROXY as user record.
|
SS Exit or Disable, restore user's as PROXY_TYPE_PROXY .
|
Can't access service anymore.
I think a handling for OS shutdown or user logoff event for restore user wininet settings is needed for fix this problem.
看了下,可能和 https://github.com/shadowsocks/shadowsocks-windows/blob/master/shadowsocks-csharp/Controller/ShadowsocksController.cs#L47 有关,因为之前只是单纯的要关闭或者是打开,现在因为会恢复用户的设置,所以,这个flag应该需要其他工作。
That's right, and also need restore user's wininet setting when:
the first two steps already covered by current codes, but we lost user settings when force Windows shutdown or user logoff. so, a handling for OS shutdown or user logoff event may need for restore.
@wongsyrone
private bool _systemProxyIsDirty = false;
这个可能要需要在磁盘上做一下持久化,防止意外关闭后忘记原来的设置。
然而目前的系统代里设置是sysproxy负责的
I tried to add a new event handle SessionEnding of SystemEvents in Main, it could catch the shutdown or user logoff successfully, but the MainController and sysproxy threads already be killed at this moment.
Fixed with write temporary "user_wininet,conf" file solution.
you guys could help to do a code review with attached two files, or continue discuss better solutions. thanks!
Line 274-279
ShadowsocksController.update.txt
Check and save user configure into a temp file!
Sysproxy.update.txt
Enhanced for log the IO exceptions when read temp conf file
Sysproxy.Update.1.txt
try 816651ebdcaa8571b117864d6fb78cd0a6217362
It works, good job!
Most helpful comment
看了下,可能和 https://github.com/shadowsocks/shadowsocks-windows/blob/master/shadowsocks-csharp/Controller/ShadowsocksController.cs#L47 有关,因为之前只是单纯的要关闭或者是打开,现在因为会恢复用户的设置,所以,这个flag应该需要其他工作。