Launcher() { orgSysProxySetting = Lib.Sys.ProxySetter.GetProxySetting(); // warn-up var cache = Cache.Instance; var cmder = Cmder.Instance; setting = Setting.Instance; pacServer = PacServer.Instance; servers = Servers.Instance; notifier = Notifier.Instance; SetCulture(setting.culture); // dependency injection pacServer.Run(setting); servers.Run(setting, pacServer, cache); cmder.Run(setting, servers, pacServer); notifier.Run(setting, servers); Application.ApplicationExit += (s, a) => OnApplicationExitHandler(false); Microsoft.Win32.SystemEvents.SessionEnding += (s, a) => OnApplicationExitHandler(true); Application.ThreadException += (s, a) => SaveExceptionAndExit( a.Exception.ToString()); AppDomain.CurrentDomain.UnhandledException += (s, a) => SaveExceptionAndExit( (a.ExceptionObject as Exception).ToString()); }
public static void UpdateProxySettingOnDemand(Model.Data.ProxyRegKeyValue proxySetting) { if (!proxySetting.IsEqualTo(GetProxySetting())) { SetProxy(proxySetting); } }
public void ClearSysProxy() { var proxy = new Model.Data.ProxyRegKeyValue(); setting.SaveSysProxySetting(proxy); Lib.Sys.ProxySetter.SetProxy(proxy); InvokeOnPACServerStatusChanged(); }
public void SetPACProx(Model.Data.PacUrlParams param) { var proxy = new Model.Data.ProxyRegKeyValue(); proxy.autoConfigUrl = GenPacUrl(param); Lib.Sys.ProxySetter.SetProxy(proxy); setting.SaveSysProxySetting(proxy); StartPacServer(); InvokeOnPACServerStatusChanged(); }
public void SetGlobalProxy(string ip, int port) { var proxy = new Model.Data.ProxyRegKeyValue(); proxy.proxyEnable = true; proxy.proxyServer = string.Format("{0}:{1}", ip, port.ToString()); Lib.Sys.ProxySetter.SetProxy(proxy); setting.SaveSysProxySetting(proxy); InvokeOnPACServerStatusChanged(); }
public static void SetPacProxy(string pacUrl) { var url = pacUrl + "?&t=" + RandomHex(8); var proxySetting = new Model.Data.ProxyRegKeyValue { autoConfigUrl = url ?? "", }; SetProxy(proxySetting); }
public static void SetProxy(Model.Data.ProxyRegKeyValue proxy) { using (var key = GetRegKey(true)) { key.SetValue("AutoConfigURL", proxy.autoConfigUrl, RegistryValueKind.String); key.SetValue("ProxyServer", proxy.proxyServer, RegistryValueKind.String); key.SetValue("ProxyEnable", proxy.proxyEnable ? 1 : 0, RegistryValueKind.DWord); } RefreshSettings(); }
public static Model.Data.ProxyRegKeyValue GetProxySetting() { var proxy = new Model.Data.ProxyRegKeyValue(); using (var key = GetRegKey(false)) { proxy.proxyServer = key.GetValue("ProxyServer", "").ToString(); proxy.proxyEnable = key.GetValue("ProxyEnable", "0").ToString() == "1"; proxy.autoConfigUrl = key.GetValue("AutoConfigURL", "").ToString(); } return(proxy); }
public static Model.Data.Enum.SystemProxyMode DetectSystemProxyMode(Model.Data.ProxyRegKeyValue proxySetting) { if (!string.IsNullOrEmpty(proxySetting.autoConfigUrl)) { return(Model.Data.Enum.SystemProxyMode.PAC); } if (proxySetting.proxyEnable) { return(Model.Data.Enum.SystemProxyMode.Global); } return(Model.Data.Enum.SystemProxyMode.None); }
public static bool IsProxyNotSet(Model.Data.ProxyRegKeyValue proxySetting) { if (!string.IsNullOrEmpty(proxySetting.autoConfigUrl)) { return(false); } if (proxySetting.proxyEnable) { return(false); } return(true); }
public static void SetGlobalProxy(int port) { var proxyUrl = string.Format( "{0}:{1}", localhost, Clamp(port, 0, 65536)); var proxySetting = new Model.Data.ProxyRegKeyValue { proxyEnable = true, proxyServer = proxyUrl, }; UpdateProxySettingOnDemand(proxySetting); }
public Model.Data.ProxyRegKeyValue GetSysProxySetting() { var empty = new Model.Data.ProxyRegKeyValue(); Model.Data.ProxyRegKeyValue proxy = null; try { proxy = JsonConvert.DeserializeObject <Model.Data.ProxyRegKeyValue>( Properties.Settings.Default.SysProxySetting); } catch { return(empty); } return(proxy ?? empty); }
public void Run(Setting setting) { this.setting = setting; orgSysProxySetting = Lib.Sys.ProxySetter.GetProxySetting(); ClearCache(); var pacSetting = setting.GetPacServerSettings(); var proxySetting = setting.GetSysProxySetting(); if (pacSetting.isAutorun || !string.IsNullOrEmpty(proxySetting.autoConfigUrl)) { RestartPacServer(); } // becareful issue #9 #3 if (!Lib.Utils.IsProxyNotSet(proxySetting)) { Lib.Sys.ProxySetter.SetProxy(proxySetting); } }
public void Run(VgcApis.IService api) { orgSysProxySetting = Lib.Sys.ProxySetter.GetProxySetting(); this.vgcApi = api; var vgcSetting = api.GetVgcSettingService(); var vgcServer = api.GetVgcServersService(); pacServer = new PacServer(); setting = new PsSettings(); serverTracker = new ServerTracker(); // dependency injection setting.Run(vgcSetting); pacServer.Run(setting); serverTracker.Run(setting, pacServer, vgcServer); setting.DebugLog("call Luncher.run"); }
public void Run(VgcApis.Models.IServices.IApiService api) { orgSysProxySetting = Lib.Sys.ProxySetter.GetProxySetting(); VgcApis.Libs.Sys.FileLogger.Info("ProxySetter: save sys proxy settings"); this.vgcApi = api; var vgcSetting = api.GetSettingService(); var vgcServer = api.GetServersService(); pacServer = new PacServer(); setting = new PsSettings(); serverTracker = new ServerTracker(); // dependency injection setting.Run(vgcSetting); pacServer.Run(setting); serverTracker.Run(setting, pacServer, vgcServer); setting.DebugLog("call Luncher.run"); }
public void SaveSysProxySetting(Model.Data.ProxyRegKeyValue proxy) { Properties.Settings.Default.SysProxySetting = JsonConvert.SerializeObject(proxy); Properties.Settings.Default.Save(); }
public void SaveSysProxySetting(Model.Data.ProxyRegKeyValue proxy) { userSettings.SysProxySetting = JsonConvert.SerializeObject(proxy); LazySaveUserSettings(); }