Exemple #1
0
        override public bool VerifyProxy(ProxyWrapper proxywrapper)
        {
            var success = true;

            success = RetrieveMetadata(proxywrapper);
            return(success);
        }
        protected bool RetrieveMetadata(ProxyWrapper proxywrapper)
        {
            var         success     = true;
            MetadataSet metadataset = null;
            bool        isInbadlist = null != _badProxyAddressList.FirstOrDefault <ProxyWrapper>(w => w.EndPoint.address == proxywrapper.EndPoint.address);

            if (proxywrapper.Proxy != null)
            {
                try
                {
                    var address   = string.Format(@"{0}?wsdl", proxywrapper.EndPoint.address);
                    var mexClient = new MetadataExchangeClient(new Uri(address), MetadataExchangeClientMode.HttpGet);
                    metadataset = mexClient.GetMetadata();
                }
                catch (Exception e)
                {
                    #if LOG // TODO : Remove when .NET 4.0 log manager is used
                    _logger.Warning(e.Message);
                    #endif
                    success = false;
                }
            }
            if (null != metadataset)
            {
                var sb = new StringBuilder();
                foreach (var section in metadataset.MetadataSections)
                {
                    sb.AppendLine(string.Format(@"{0}{1}", section.Identifier.ToString(), Environment.NewLine));
                }
                VerifyProxyResults = sb.ToString();
            }

            return(success);
        }
        private void UpdateProxyDictionary(List <endpoint> EndpointList, bool usedefaultVerifier = false)
        {
            _badProxyAddressList.Clear();
            _proxydictionary.Clear();
            _proxyHelthymonitorTimer.Enabled = false;

            var idx = 0;

            EndpointList.ForEach(endpoint =>
            {
                var proxywrapper = new ProxyWrapper
                {
                    Proxy    = CreateProxy(endpoint),
                    EndPoint = endpoint
                };

                UpdateBadProxyList(proxywrapper, usedefaultVerifier);

                if (!_proxydictionary.ContainsKey(idx))
                {
                    _proxydictionary.Add(idx, proxywrapper);
                    idx++;
                }
            });
            _proxyHelthymonitorTimer.Enabled = true;
        }
        protected void UpdateBadProxyList(ProxyWrapper proxywrapper, bool usedefaultVerifier = false)
        {
            var  success     = false;
            bool isInbadlist = null != _badProxyAddressList.FirstOrDefault <ProxyWrapper>(w => w.EndPoint.address == proxywrapper.EndPoint.address);

            if (usedefaultVerifier)
            {
                success = RetrieveMetadata(proxywrapper);
            }
            else
            {
                success = VerifyProxy(proxywrapper);
            }

            if (!(success || isInbadlist))
            {
                _badProxyAddressList.Add(proxywrapper);
            }
            else if (success && isInbadlist)
            {
                _badProxyAddressList.Remove(proxywrapper);
            }
        }
 abstract public bool VerifyProxy(ProxyWrapper proxywrapper);