public static void Stop() { if (!proxyRunning) { throw new Exception("Proxy is not running."); } var setAsSystemProxy = ProxyEndPoints.OfType <ExplicitProxyEndPoint>().Any(x => x.IsSystemHttpProxy || x.IsSystemHttpsProxy); if (setAsSystemProxy) { SystemProxyHelper.DisableAllProxy(); #if !DEBUG FireFoxHelper.RemoveFirefox(); #endif } foreach (var endPoint in ProxyEndPoints) { endPoint.listener.Stop(); } CertManager.Dispose(); Quit(); proxyRunning = false; }
private void FormMain_FormClosed(object sender, FormClosedEventArgs e) { #if !DEBUG // if (Properties.Settings.Default.isProtected) //ProxyRoutines.SetProxy(false); SystemProxyHelper.DisableAllProxy(); FireFoxHelper.RemoveFirefox(); #endif log.Info("FormMain_FormClosed Unset Proxy!"); }
public static void Stop() { if (SetAsSystemProxy) { SystemProxyHelper.DisableAllProxy(); FireFoxHelper.RemoveFirefox(); } _listener.Stop(); CertManager.Dispose(); }
public static void Stop() { if (SetAsSystemProxy) { SystemProxyHelper.DisableAllProxy(); FireFoxHelper.RemoveFirefox(); } ShouldListen = false; listener.Stop(); listenerThread.Interrupt(); }
private void TurnOffProxy() { if (WechatForm.Auth()) { #if !DEBUG //ProxyRoutines.SetProxy(false); SystemProxyHelper.DisableAllProxy(); FireFoxHelper.RemoveFirefox(); #endif //notify_icon_main.Icon = Properties.Resources.off; tool_strip_menu_item_toggle_onff.Checked = false; //toggleOnOffButton.Image = Properties.Resources.powerblack_small; Properties.Settings.Default.isProtected = false; Properties.Settings.Default.Save(); //同时设置 TurnOffAutoStart(); } }
public static void DisableProxy() { //unset proxy again to make sure #if !DEBUG //if (System.Environment.OSVersion.Version.Major<=6 && System.Environment.OSVersion.Version.Minor<=1) //{ // log.Info("Disable Proxy Win7!"); // try // { // ProxyRoutines.SetProxy(false); // } // catch (Exception exp) // { log.Error(exp.ToString()); } //} //else { try { if (GetProxy()) { log.Info("Disable Proxy!"); //在关机时,不能refresh,否则会导致无法修改成功,其他时候则要刷新,否则会导致无法刷新 if (kCloseReason == CloseReason.WindowsShutDown) { if (System.Environment.OSVersion.Version.Major <= 6 && System.Environment.OSVersion.Version.Minor <= 1) { log.Info("Win7 Disable proxy on Exit!"); TrollProxyHelper.RemoveHttpProxyWithRefresh(); } else { log.Info("Disable proxy without Refresh!"); SystemProxyHelper.DisableAllProxyWithourRestoreAndRefresh(); } //int tryTimes = 10; //while (tryTimes-- > 0) //{ //SystemProxyHelper.DisableAllProxyWithourRestore(); //reg.SetValue("ProxyEnable", 0); //reg.Flush(); ////read again //if ((int)reg.GetValue("ProxyEnable") != 0) // Thread.Sleep(50); ////else // //break; RegistryKey reg = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true); log.Info("ProxyEnable Value: " + reg.GetValue("ProxyEnable")); //} } else { if (System.Environment.OSVersion.Version.Major <= 6 && System.Environment.OSVersion.Version.Minor <= 1) { log.Info("Win7 Disable proxy!"); TrollProxyHelper.RemoveHttpProxy(); } else { log.Info("Disable proxy with Refresh!"); SystemProxyHelper.DisableAllProxyWithourRestore(); } } FireFoxHelper.RemoveFirefox(); } } catch (Exception exp) { log.Error(exp.ToString()); } } #endif }