コード例 #1
0
        public static bool Update(Config config, bool forceDisable)
        {
            int type = config.listenerType;

            if (forceDisable)
            {
                type = 0;
            }

            try
            {
                if (type != 0)
                {
                    var port = Global.sysAgentPort;
                    if (port <= 0)
                    {
                        return(false);
                    }
                    if (type == 1)
                    {
                        PACServerHandle.Stop();
                        PACFileWatcherHandle.StopWatch();
                        SysProxyHandle.SetIEProxy(true, true, "127.0.0.1:" + port, null);
                    }
                    else if (type == 2)
                    {
                        string pacUrl = GetPacUrl();
                        SysProxyHandle.SetIEProxy(true, false, null, pacUrl);
                        PACServerHandle.Stop();
                        PACServerHandle.Init(config);
                        PACFileWatcherHandle.StartWatch(config);
                    }
                    else if (type == 3)
                    {
                        PACServerHandle.Stop();
                        PACFileWatcherHandle.StopWatch();
                        SysProxyHandle.SetIEProxy(false, false, null, null);
                    }
                    else if (type == 4)
                    {
                        string pacUrl = GetPacUrl();
                        SysProxyHandle.SetIEProxy(false, false, null, null);
                        PACServerHandle.Stop();
                        PACServerHandle.Init(config);
                        PACFileWatcherHandle.StartWatch(config);
                    }
                }
                else
                {
                    SysProxyHandle.SetIEProxy(false, false, null, null);
                    PACServerHandle.Stop();
                    PACFileWatcherHandle.StopWatch();
                }
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
            return(true);
        }
コード例 #2
0
 public static void ReSetPACProxy(Config config)
 {
     if (config.listenerType == 2)
     {
         SysProxyHandle.SetIEProxy(false, false, null, null);
         PACServerHandle.Stop();
     }
     Update(config, false);
 }
コード例 #3
0
        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);
                    }
                    else if (type == 2)
                    {
                        string pacUrl = GetPacUrl();
                        ProxySetting.SetProxy(pacUrl, "", 4);
                        //PACServerHandle.Stop();
                        PACServerHandle.Init(config);
                    }
                    else if (type == 3)
                    {
                        //PACServerHandle.Stop();
                        ProxySetting.UnsetProxy();
                    }
                    else if (type == 4)
                    {
                        string pacUrl = GetPacUrl();
                        ProxySetting.UnsetProxy();
                        //PACServerHandle.Stop();
                        PACServerHandle.Init(config);
                    }
                }
                else
                {
                    ProxySetting.UnsetProxy();
                    //PACServerHandle.Stop();
                }
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
            return(true);
        }
コード例 #4
0
        public 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();
                        SysProxyHandle.SetIEProxy(true, true, $"{Global.Loopback}:{port}", null);
                    }
                    else if (type == 2)
                    {
                        string pacUrl = GetPacUrl();
                        SysProxyHandle.SetIEProxy(true, false, null, pacUrl);
                        //PACServerHandle.Stop();
                        PACServerHandle.Init(config);
                    }
                    else if (type == 3)
                    {
                        //PACServerHandle.Stop();
                        SysProxyHandle.SetIEProxy(false, false, null, null);
                    }
                    else if (type == 4)
                    {
                        string pacUrl = GetPacUrl();
                        SysProxyHandle.SetIEProxy(false, false, null, null);
                        //PACServerHandle.Stop();
                        PACServerHandle.Init(config);
                    }
                }
                else
                {
                    SysProxyHandle.SetIEProxy(false, false, null, null);
                    //PACServerHandle.Stop();
                }
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
            return(true);
        }
コード例 #5
0
ファイル: HttpProxyHandle.cs プロジェクト: zredb/v2rayN
        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);
        }