Example #1
0
        public void Init()
        {
            pacSetting = new PacSetting();
//			URLPattern up = new URLPattern("http://.*.baidu.com/.*");
//			//up.NecessaryKeyword.Add("百度");
//			up.ForbiddenKeywords.Add("五星体育");
//			up.NeedValidation = true;
//			pacSetting.LoadURLPattern(up);
//			PacSettingParser.ReadConfig("./Config/pac.xml",pacSetting);

            dnsCache = new DNSCache();

            targetConnectionPool               = new TargetConnectionPool();
            targetResponseValidator            = new TargetResponseValidator();
            targetResponseValidator.PacSetting = pacSetting;



            //targetConnectionPool.StartDaemon();


            proxyManager = new ProxyManager();
//			var wppp = new WebPageProxyProvider();
//			wppp.Sources.Add(new WebPageProxySource
//			                    {
//			                        URL = "http://proxy.ipcn.org/proxylist.html",
//			                        Pattern = @"(?<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s*):(?<port>\s*\d{1,5})"
//			                    });
//			proxyManager.ProxyProviders.Add(wppp);

            proxyManager.ProxyValidator = new ProxyValidator();
            //load validate conditions
//			var vc = new ProxyValidateCondition();
//			vc.Url = "http://www.baidu.com";
//			vc.Keywords.Add("百度");
//			vc.Keywords.Add("html");
//			proxyManager.ProxyValidator.ValidateConditions.Add(vc);

//			proxyValidator.ValidateConditions.AddRange(ProxyValidateConditionParser.ReadConfig("./Config/validate.xml"));

            selectiveProxyGuide              = new SelectiveProxyGuide();
            selectiveProxyGuide.DnsCache     = dnsCache;
            selectiveProxyGuide.PacSetting   = pacSetting;
            selectiveProxyGuide.ProxyManager = proxyManager;

            listener = new Listener();
            listener.TargetConnectionPool    = targetConnectionPool;
            listener.TargetConnctionGuide    = selectiveProxyGuide;
            listener.TargetResponseValidator = targetResponseValidator;


            proxyManager.OnValidateCompleted += new RunWorkerCompletedEventHandler(DoValidateCompleted);

            IEProxySetter = new IEProxySetter();
            pacFilePath   = Path.GetFullPath("my.pac");
        }
Example #2
0
        static void v8()
        {
            ManualResetEvent mre = new ManualResetEvent(false);

            l = new Listener();
            SelectiveProxyGuide spg = new SelectiveProxyGuide();

            spg.DnsCache   = new DNSCache();
            spg.PacSetting = new PacSetting();
//			spg.PacSetting.AddURLPattern(@"http://.*\.baidu\.com");

            pm = new ProxyManager();
            WebPageProxyProvider wppp = new WebPageProxyProvider();

            wppp.Sources.Add(new WebPageProxySource
            {
                URL     = "http://proxy.ipcn.org/proxylist.html",
                Pattern = @"(?<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s*):(?<port>\s*\d{1,5})"
            });

            pm.ProxyProviders.Add(wppp);

            ProxyValidator         pv = new ProxyValidator();
            ProxyValidateCondition vc = new ProxyValidateCondition();

            vc.Url = "http://www.baidu.com";
            vc.Keywords.Add("百度");
            vc.Keywords.Add("html");
            pv.ValidateConditions.Add(vc);

            pm.ProxyValidator = pv;

            spg.ProxyManager       = pm;
            l.TargetConnctionGuide = spg;

            pm.StartDownloadProxies(false);

            l.StartListener();
            mre.WaitOne();
        }