public static void StartWatch(Config config)
 {
     if (fileSystemWatcher == null)
     {
         fileSystemWatcher              = new FileSystemWatcher(Application.StartupPath);
         fileSystemWatcher.Filter       = "pac.txt";
         fileSystemWatcher.NotifyFilter = NotifyFilters.Size;
         fileSystemWatcher.Changed     += (sender, args) =>
         {
             var fileInfo = new FileInfo(args.FullPath);
             if (fileSize != fileInfo.Length)
             {
                 fileSize = fileInfo.Length;
                 SystemProxyHandle.ReSetPACProxy(config);
             }
         };
     }
     fileSystemWatcher.EnableRaisingEvents = true;
 }
Exemple #2
0
        /// <summary>
        /// 关闭系统代理
        /// </summary>
        private void UnsetSysAgent()
        {
            try
            {
                SystemProxyHandle.Update(_config, true);
                //开启全局代理则关闭
                if (Global.setSysAgent)
                {
                    //ProxySetting.UnsetProxy();

                    if (privoxyHandler != null)
                    {
                        privoxyHandler.Stop();
                    }
                    Global.setSysAgent = false;
                }
            }
            catch
            {
            }
        }
Exemple #3
0
 /// <summary>
 /// V2ray重启
 /// </summary>
 private void V2rayRestart()
 {
     V2rayStop();
     V2rayStart();
     SystemProxyHandle.ReSetPACProxy(_config);
 }