diff --git a/shadowsocks-csharp/Controller/System/SystemProxy.cs b/shadowsocks-csharp/Controller/System/SystemProxy.cs index 1f5b685f..dbb6548f 100644 --- a/shadowsocks-csharp/Controller/System/SystemProxy.cs +++ b/shadowsocks-csharp/Controller/System/SystemProxy.cs @@ -7,16 +7,13 @@ namespace Shadowsocks.Controller { public static class SystemProxy { - private static bool failed = false; - private static string GetTimestamp(DateTime value) { return value.ToString("yyyyMMddHHmmssfff"); } - public static void Update(Configuration config, bool forceDisable, PACServer pacSrv) + public static void Update(Configuration config, bool forceDisable, PACServer pacSrv, bool noRetry = false) { - if (failed) return; bool global = config.global; bool enabled = config.enabled; @@ -55,18 +52,18 @@ namespace Shadowsocks.Controller catch (ProxyException ex) { Logging.LogUsefulException(ex); - switch (ex.Type) + if (ex.Type != ProxyExceptionType.Unspecific && !noRetry) + { + var ret = MessageBox.Show(I18N.GetString("Error occured when process proxy setting, do you want reset current setting and retry?"), I18N.GetString("Shadowsocks"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (ret == DialogResult.Yes) + { + Sysproxy.ResetIEProxy(); + Update(config, forceDisable, pacSrv, true); + } + } + else { - case ProxyExceptionType.FailToRun: - MessageBox.Show(I18N.GetString("Error when running sysproxy, check your proxy config"), I18N.GetString("Shadowsocks")); - break; - case ProxyExceptionType.QueryReturnMalformed: - case ProxyExceptionType.QueryReturnEmpty: - MessageBox.Show(I18N.GetString("Can't query proxy config, check your proxy config"), I18N.GetString("Shadowsocks")); - break; - case ProxyExceptionType.SysproxyExitError: - MessageBox.Show(I18N.GetString("Sysproxy return a error:") + ex.Message, I18N.GetString("Shadowsocks")); - break; + MessageBox.Show(I18N.GetString("Unrecoverable proxy setting error occured, see log for detail"), I18N.GetString("Shadowsocks"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } diff --git a/shadowsocks-csharp/Data/ja.txt b/shadowsocks-csharp/Data/ja.txt index e3fb3e5e..f8e609ee 100644 --- a/shadowsocks-csharp/Data/ja.txt +++ b/shadowsocks-csharp/Data/ja.txt @@ -149,6 +149,5 @@ Register hotkey failed=ホットキーの登錄に失敗しました。 Cannot parse hotkey: {0}=ホットキーを解析できません: {0} Timeout is invalid, it should not exceed {0}=タイムアウト値が無効です。{0} 以下の値を指定して下さい。 -Error when running sysproxy, check your proxy config=执行sysproxy时发生错误,请检查你的系统代理设置 -Can't query proxy config, check your proxy config=无法解析代理配置,请检查你的系统代理设置 -Sysproxy return a error:=sysproxy报告了一个错误: \ No newline at end of file +Error occured when process proxy setting, do you want reset current setting and retry?=处理代理设置时发生错误,是否重置当前代理设置并重试? +Unrecoverable proxy setting error occured, see log for detail=发生不可恢复的代理设置错误,查看日志以取得详情 \ No newline at end of file diff --git a/shadowsocks-csharp/Data/zh_CN.txt b/shadowsocks-csharp/Data/zh_CN.txt index 533f8e46..9cc80ff8 100644 --- a/shadowsocks-csharp/Data/zh_CN.txt +++ b/shadowsocks-csharp/Data/zh_CN.txt @@ -149,6 +149,5 @@ Register hotkey failed=注册快捷键失败 Cannot parse hotkey: {0}=解析快捷键失败: {0} Timeout is invalid, it should not exceed {0}=超时无效,不应超过 {0} -Error when running sysproxy, check your proxy config=执行sysproxy时发生错误,请检查你的系统代理设置 -Can't query proxy config, check your proxy config=无法解析代理配置,请检查你的系统代理设置 -Sysproxy return a error:=sysproxy报告了一个错误: \ No newline at end of file +Error occured when process proxy setting, do you want reset current setting and retry?=处理代理设置时发生错误,是否重置当前代理设置并重试? +Unrecoverable proxy setting error occured, see log for detail=发生不可恢复的代理设置错误,查看日志以取得详情 \ No newline at end of file diff --git a/shadowsocks-csharp/Data/zh_TW.txt b/shadowsocks-csharp/Data/zh_TW.txt index ffbf7e0b..4365d07a 100644 --- a/shadowsocks-csharp/Data/zh_TW.txt +++ b/shadowsocks-csharp/Data/zh_TW.txt @@ -149,6 +149,5 @@ Register hotkey failed=註冊快速鍵失敗 Cannot parse hotkey: {0}=剖析快速鍵失敗: {0} Timeout is invalid, it should not exceed {0}=逾時無效,不應超過 {0} -Error when running sysproxy, check your proxy config=执行sysproxy时发生错误,请检查你的系统代理设置 -Can't query proxy config, check your proxy config=无法解析代理配置,请检查你的系统代理设置 -Sysproxy return a error:=sysproxy报告了一个错误: \ No newline at end of file +Error occured when process proxy setting, do you want reset current setting and retry?=处理代理设置时发生错误,是否重置当前代理设置并重试? +Unrecoverable proxy setting error occured, see log for detail=发生不可恢复的代理设置错误,查看日志以取得详情 \ No newline at end of file diff --git a/shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs b/shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs index a8b948d9..c28d8c52 100644 --- a/shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs +++ b/shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs @@ -82,6 +82,26 @@ namespace Shadowsocks.Util.SystemProxy ExecSysproxy(arguments); } + + // set system proxy to 1 (null) (null) (null) + public static bool ResetIEProxy() + { + try + { + // clear user-wininet.json + _userSettings = new SysproxyConfig(); + Save(); + // clear system setting + ExecSysproxy("set 1 - - -"); + } + catch (Exception e) + { + return false; + } + + return true; + } + private static void ExecSysproxy(string arguments) { // using event to avoid hanging when redirect standard output/error @@ -146,8 +166,6 @@ namespace Shadowsocks.Util.SystemProxy // log the arguements throw new ProxyException(ProxyExceptionType.FailToRun, process.StartInfo.Arguments, e); } - - var stderr = error.ToString(); var stdout = output.ToString();