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);
            }
        }
        public void DirectTest()
        {
            using var service = new ProxyService();
            var old = service.Query();

            try
            {
                Assert.IsTrue(service.Direct());
                var status = service.Query();
                Assert.IsTrue(status.IsDirect);
                Assert.IsFalse(status.IsProxy);
                Assert.IsFalse(status.IsAutoProxyUrl);
                Assert.IsTrue(status.IsAutoDetect);
            }
            finally
            {
                Assert.IsTrue(service.Set(old));
                Assert.AreEqual(old, service.Query());
            }
        }