public void GlobalTest()
        {
            using var service = new ProxyService
                  {
                      Server = @"中文测试1919810",
                      Bypass = string.Join(@";", ProxyService.LanIp)
                  };
            var idn = new IdnMapping();
            var old = service.Query();

            try
            {
                Assert.IsTrue(service.Global());
                var status = service.Query();
                Assert.IsTrue(status.IsDirect);
                Assert.IsTrue(status.IsProxy);
                Assert.IsFalse(status.IsAutoProxyUrl);
                Assert.IsFalse(status.IsAutoDetect);
                Assert.AreEqual(idn.GetAscii(service.Server), status.ProxyServer);
                Assert.AreEqual(idn.GetAscii(service.Bypass), status.ProxyBypass);
            }
            finally
            {
                Assert.IsTrue(service.Set(old));
                Assert.AreEqual(old, service.Query());
            }
        }
        public static void Update(Configuration config, PACServer pacSrv)
        {
            var sysProxyMode = config.SysProxyMode;

            if (sysProxyMode == ProxyMode.NoModify)
            {
                Restore();
                return;
            }
            try
            {
                using var proxy = new ProxyService();

                switch (sysProxyMode)
                {
                case ProxyMode.Direct:
                {
                    proxy.Direct();
                    break;
                }

                case ProxyMode.Pac:
                {
                    proxy.AutoConfigUrl = pacSrv.PacUrl;
                    proxy.Pac();
                    break;
                }

                case ProxyMode.Global:
                {
                    proxy.Server = $@"localhost:{config.LocalPort}";
                    proxy.Bypass = string.Join(@";", ProxyService.LanIp);
                    proxy.Global();
                    break;
                }

                default:
                {
                    Restore();
                    break;
                }
                }
            }
            catch (Exception e)
            {
                Logging.LogUsefulException(e);
            }
        }