public static bool UpdateSysProxy(Config config, bool forceDisable) { var type = config.sysProxyType; if (forceDisable && type == ESysProxyType.ForcedChange) { type = ESysProxyType.ForcedClear; } try { Global.httpPort = config.GetLocalPort(Global.InboundHttp); int port = Global.httpPort; if (port <= 0) { return(false); } if (type == ESysProxyType.ForcedChange) { SysProxyHandle.SetIEProxy(true, true, $"{Global.Loopback}:{port}"); } else if (type == ESysProxyType.ForcedClear) { SysProxyHandle.ResetIEProxy(); } else if (type == ESysProxyType.Unchanged) { } } catch (Exception ex) { Utils.SaveLog(ex.Message, ex); } return(true); }
private static bool Update(Config config, bool forceDisable) { // ListenerType type = config.listenerType; var type = ListenerType.noHttpProxy; if (forceDisable) { type = ListenerType.noHttpProxy; } try { if (type != ListenerType.noHttpProxy) { int port = Global.httpPort; if (port <= 0) { return(false); } if (type == ListenerType.GlobalHttp) { //ProxySetting.SetProxy($"{Global.Loopback}:{port}", Global.IEProxyExceptions, 2); SysProxyHandle.SetIEProxy(true, true, $"{Global.Loopback}:{port}"); } else if (type == ListenerType.HttpOpenAndClear) { SysProxyHandle.ResetIEProxy(); } else if (type == ListenerType.HttpOpenOnly) { //SysProxyHandle.ResetIEProxy(); } } else { SysProxyHandle.ResetIEProxy(); } } catch (Exception ex) { Utils.SaveLog(ex.Message, ex); } return(true); }
public static bool UpdateSysProxy(Config config, bool forceDisable) { var type = config.sysProxyType; if (forceDisable && type == ESysProxyType.ForcedChange) { type = ESysProxyType.ForcedClear; } try { Global.httpPort = config.GetLocalPort(Global.InboundHttp); int port = Global.httpPort; if (port <= 0) { return(false); } if (type == ESysProxyType.ForcedChange) { SysProxyHandle.SetIEProxy(true, true, $"{Global.Loopback}:{port}"); } else if (type == ESysProxyType.ForcedClear) { //TODO To be verified Utils.RegWriteValue(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", 0); SysProxyHandle.ResetIEProxy(); } else if (type == ESysProxyType.Unchanged) { } } catch (Exception ex) { Utils.SaveLog(ex.Message, ex); } return(true); }
private static bool Update(Config config, bool forceDisable) { int type = config.listenerType; if (forceDisable) { type = 0; } try { if (type != 0) { var port = Global.httpPort; if (port <= 0) { return(false); } if (type == 1) { //PACServerHandle.Stop(); //ProxySetting.SetProxy($"{Global.Loopback}:{port}", Global.IEProxyExceptions, 2); SysProxyHandle.SetIEProxy(true, true, $"{Global.Loopback}:{port}"); } else if (type == 2) { string pacUrl = GetPacUrl(); //ProxySetting.SetProxy(pacUrl, "", 4); SysProxyHandle.SetIEProxy(true, false, pacUrl); //PACServerHandle.Stop(); PACServerHandle.Init(config); } else if (type == 3) { //PACServerHandle.Stop(); SysProxyHandle.ResetIEProxy(); } else if (type == 4) { string pacUrl = GetPacUrl(); SysProxyHandle.ResetIEProxy(); //PACServerHandle.Stop(); PACServerHandle.Init(config); } else if (type == 5) { //PACServerHandle.Stop(); //SysProxyHandle.ResetIEProxy(); } else if (type == 6) { string pacUrl = GetPacUrl(); //SysProxyHandle.ResetIEProxy(); //PACServerHandle.Stop(); PACServerHandle.Init(config); } } else { SysProxyHandle.ResetIEProxy(); //PACServerHandle.Stop(); } } catch (Exception ex) { Utils.SaveLog(ex.Message, ex); } return(true); }
private static bool Update(Config config, bool forceDisable) { ListenerType type = config.listenerType; if (forceDisable) { type = ListenerType.noHttpProxy; } try { if (type != ListenerType.noHttpProxy) { int port = Global.httpPort; if (port <= 0) { return(false); } if (type == ListenerType.GlobalHttp) { //PACServerHandle.Stop(); //ProxySetting.SetProxy($"{Global.Loopback}:{port}", Global.IEProxyExceptions, 2); SysProxyHandle.SetIEProxy(true, true, $"{Global.Loopback}:{port}"); } else if (type == ListenerType.GlobalPac) { string pacUrl = GetPacUrl(); //ProxySetting.SetProxy(pacUrl, "", 4); SysProxyHandle.SetIEProxy(true, false, pacUrl); //PACServerHandle.Stop(); PACServerHandle.Init(config); } else if (type == ListenerType.HttpOpenAndClear) { //PACServerHandle.Stop(); SysProxyHandle.ResetIEProxy(); } else if (type == ListenerType.PacOpenAndClear) { string pacUrl = GetPacUrl(); SysProxyHandle.ResetIEProxy(); //PACServerHandle.Stop(); PACServerHandle.Init(config); } else if (type == ListenerType.HttpOpenOnly) { //PACServerHandle.Stop(); //SysProxyHandle.ResetIEProxy(); } else if (type == ListenerType.PacOpenOnly) { string pacUrl = GetPacUrl(); //SysProxyHandle.ResetIEProxy(); //PACServerHandle.Stop(); PACServerHandle.Init(config); } } else { SysProxyHandle.ResetIEProxy(); //PACServerHandle.Stop(); } } catch (Exception ex) { Utils.SaveLog(ex.Message, ex); } return(true); }